Skip to main content

Troubleshooting

Synced from returns-processing

This page is a copy of docs/docs/operations/troubleshooting.md on develop, derived from that repository's code. Edit it there, then re-sync.

Process and boot​

SymptomCauseFix
invalid configuration: DATABASE_URL is required: this service runs on real Postgres (exit 1)no DSNset DATABASE_URL; there is no fallback runtime
... KAFKA_BROKERS is required ...no brokersset KAFKA_BROKERS; Kafka is mandatory, not optional
... PRODUCT_CLASSIFICATION_CONSUMER_GROUP is required ... (same for ORDER_LINES_, MANIFEST_)a pinned group id is missingset it; the name is pinned in .claude/rules/integration-events.md
Boot hangs/loops on migrations behind PgBouncergolang-migrate's advisory lock is session-scoped; PgBouncer transaction pooling cannot honour itset MIGRATIONS_DATABASE_URL to a direct session DSN
Pod restarts with service exited with error naming a consumera consumer died (any error but a clean cancel) — deliberate: a half-alive service on frozen local copies is worseread the consumer's error line above it; usually broker unreachable or a poison loop

Events not flowing out​

SymptomCauseFix
outbox table growing, nothing on warehouse.returns-processing.eventsbroker unreachable: rows back off, the relay pass stopsfix broker reachability (/readyz says not ready: kafka); rows drain themselves, oldest first
ERROR row reached the attempt cap ... re-arm itone row failed OUTBOX_MAX_ATTEMPTS (default 20) times and is excluded from claimsfix the cause, then UPDATE outbox SET attempts = 0, next_attempt_at = now() WHERE id = '<uuid>'
WARN dead-lettered a row the encoder refusesthe row can never be encoded (unknown event, malformed payload) — deterministicinspect it on warehouse.returns-processing.events.dlq; not retryable by design
Message on the DLQ onlyit is poison, and the message behind it still appliedverify the effect you expected from the NEXT message, not this one

Events not flowing in (local copies empty)​

SymptomCauseFix
POST /returns answers 409 return-not-authorizable, code LINE_NOT_MANIFESTEDthe (order, line) has no manifested work unit yet — or the manifest/allocation consumer never rancheck the consumer groups are consuming (warehouse.fulfillment.events, group MANIFEST_CONSUMER_GROUP); authorizations fail CLOSED until the facts arrive, by design
ProductClassified applied once, then never againversion gate: only version > stored appliescorrect behaviour (ADR 0003); an older event is a store-no-op
WARN not a valid CloudEvent in the logsa flat envelope or garbage on a consumed topicskipped and committed past by design; find the producer of that message
Same event applied twice?it cannot: the CloudEvents id is claimed in the same transaction as the effectcheck processed_events for the id if you suspect otherwise

Decisions look wrong​

SymptomCauseFix
Grade A answered DISPOSE, not RESTOCKa guardrail demoted it: the SKU is DISPOSE-classified, or hazmat without a DOT ratingthat is fail-closed by design (ADR 0002); check get_disposition_policy and the SKU's classification
RESTOCK for grade Cimpossible from Decidean operator override did it — check the disposition's supersedes/reason
409 line-already-inspecteda line is graded exactly oncecorrect the DECISION with an override, never a re-inspection
422 override-reason-requiredthe reason field is mandatory (1–500 chars)send it; the override explains itself
Two dispositions, one linethe second carries supersedes = the firstthe ORIGINAL is immutable — audit trail, not a bug

REST problem types​

All errors are RFC 7807 with type = https://errors.returns-processing.warehouse-systems.dev/<slug>:

SlugMeaning / fix
malformed-request-bodynot strict JSON, unknown field, or a NUL byte — send exactly the documented fields
invalid-quantity / invalid-line / invalid-grade / invalid-policyvalue out of range or not in the enum
idempotency-key-requiredevery write (4 POSTs + the policy PUT) needs an Idempotency-Key header
idempotency-key-reused (409)the same key was sent with a DIFFERENT method, path or body — one key per logical request
rma-not-found / receipt-not-found / disposition-not-found / policy-not-foundunknown id (or no policy declared yet)
return-not-authorizablerejection code in the body: LINE_NOT_MANIFESTED, RETURN_WINDOW_EXPIRED, OPEN_RMA_EXISTS, QUANTITY_EXCEEDS_POLICY
open-rma-existsone open RMA per (order, line); the existing one must close first
rma-not-receivablea receipt was opened against an RMA that is not in AUTHORIZED state
line-already-inspected / inspected-exceeds-receivedgrading rules (ADR 0002)
override-reason-requiredan override must explain itself
concurrent-modificationoptimistic version guard lost — reload, re-apply
dependency-unavailablePostgres or Kafka unreachable behind 503 /readyz — not a client error
internal-erroranything unexpected; the log line carries the cause

Idempotency-Key behaviour worth knowing​

The FIRST answer for a key is stored and replayed — including 4xx problem documents. A 5xx is never stored (safe to retry the same key). Replaying a stored 201 does NOT create a second RMA, receipt or disposition; the stored body is returned verbatim.