Storefront has been decoupled into micro-frontends with a dedicated commerce app and shared shell.

Read the architecture guide →

Validation, Errors, and Resilience

Shared request validation, HTTP error mapping, and capability-specific retry and duplicate-request behavior.

Cross-cutting Concept

Purpose and Scope

Validation, error handling, and resilience protect public and internal boundaries from malformed work, overload, partial failure, and repeated delivery. These rules apply to HTTP and RPC endpoints, message consumers, external calls, schedulers, and workflows across every building block.

Visual Reference

Request Validation and Recovery

Loading graph...

Core Rules and Standards

  1. Validate at the trust boundary. Reject malformed shape, ranges, identities, required fields, and authorization state before domain execution.
  2. Use a stable error contract. Return machine-readable problem details with type, status, title, detail, instance, and correlation without exposing stack traces or secrets.
  3. Separate expected and unexpected failures. Validation and not-found conditions are caller errors; conflicts represent state; unhandled faults indicate incidents.
  4. Bound overload controls. Limit concurrency and request rate per source or user and shed work with a retry hint where appropriate.
  5. Make mutations retry-safe. Require an operation identifier for duplicate-sensitive writes and retain intent until the authoritative outcome is known.
  6. Classify retries. Retry only bounded transient faults; never retry validation, authorization, permanent deserialization, or destructive ambiguous work automatically.
  7. Compensate or confirm. After a timeout or partial failure, verify authoritative state or execute an explicitly approved compensating action.
Warning

A retry, acknowledgement, or successful transport call does not prove business completion. Consumers and callers must verify final state or receive a durable outcome.

Mechanism / How It Works

ConditionStandard Response
Invalid inputReturn 400 with field-level or operation-level problem details
Unauthenticated or forbiddenReturn 401 or 403 without leaking protected resource details
Missing resourceReturn 404 unless availability concealment is an explicit policy
State conflict or duplicate operationReturn 409 or the standard precondition response and preserve the existing state
Preconditions not metReturn 412 and direct the caller to refresh the authoritative version
Capacity exceededReturn 429 with retry guidance
Unexpected faultReturn 500 or 503 with correlation; log full diagnostics only inside protected systems

Resilience Pattern

StepRule
AdmissionEnforce transport limits and request or user quotas
IdempotencyCreate or confirm the operation key before executing side effects
ValidationRun schema and domain preconditions before persistence
ExecutionApply operation-specific timeouts and cancellation
RetryUse bounded attempts, jitter, and backoff for classified transient faults
ContainmentUse circuit-breaking or fail-fast behavior to protect downstream dependencies
RecoveryReconcile, replay, compensate, or escalate according to the capability’s state model

Verification and Governance

  • Test invalid, unauthorized, duplicate, concurrent, timed-out, and unavailable-dependency cases.
  • Verify that 429 responses include retry guidance and that retries do not amplify load.
  • Confirm idempotency keys are removed or released only after a safe retry outcome.
  • Require a final-state check or compensation test for every distributed mutation.
  • Contracts and MessagingCustom DocContracts and MessagingOwned APIs and events connect independently maintained BookWorm capabilities without sharing business state.Ownerplatform-engineering-teamOpen doc — Delivery guarantees and envelope handling.
  • ObservabilityCustom DocObservabilityShared structured logging, OpenTelemetry signals, and health checks support diagnosis across BookWorm services.Ownerplatform-engineering-teamOpen doc — Trace and error correlation.
  • Runtime ViewCustom DocRuntime ViewRepresentative BookWorm runtime scenarios across commerce, discovery, customer feedback, and platform operations.Ownerarchitecture-enabling-teamOpen doc — End-to-end exception and compensation scenarios.