Skip to main content

Troubleshooting

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

Network return outcomes​

SymptomCauseFix
WARN network return outcome refused but released; the next tick retries ... with refusal=not-foundthe network has not consumed the return advice yet (its copy is event-fed)nothing: the outcome stays PENDING and is retried under the same key every tick, for 24 h from outcome_since
the same WARN with refusal=vendor-suspendedthe vendor is suspended at the networkhave an operator reinstate the vendor there; the next tick passes. After 24 h the outcome is FAILED
the same WARN with refusal=concurrent-update or illegal-transitionanother writer won, or the advice is not yet in the state the outcome needsnothing, it clears on a later tick
outcome FAILED, outcome_errors reads ... answered 404 not-found ...a released refusal outlived the 24 h windowfind out with the network's operators why it never consumed the advice; the service has no re-arm of a FAILED outcome (not decided, ADR 0013)
outcome FAILED at once, outcome_errors names validation-failed, ack-window-closed or a slug you do not knowa final refusal, or a slug the table of ADR 0013 does not classify (unknown is terminal)read the callee's detail in the text; if the slug is new and should retry, add it to refusal_classes.go with the network's class
refusal_spec_test fails after a pin refreshthe network named or released a problem type the table does not classifyread the failure line, classify the slug from the network's class table (its ADR 0015) and update the table and ADR 0013 together

Decisions look wrong​

SymptomCauseFix
Grade A answered something other than RESTOCK (DISPOSE unless the policy's vetoOutcome says otherwise)a guardrail demoted a RESTOCK to the veto outcome: the SKU is DISPOSE-classified (force:DISPOSE), 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
400 override-reason-requiredthe reason field is mandatory and must not be blank (there is no maximum length)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-authorizable (409)rejection code at the start of the detail: LINE_NOT_MANIFESTED, RETURN_WINDOW_EXPIRED, QUANTITY_EXCEEDS_POLICY or ORDER_LINE_NOT_ALLOCATED (the line is not in the allocations copy; fail-closed). An open RMA is the separate slug open-rma-exists
open-rma-existsone open RMA per (order, line); the existing one must close first
rma-not-receivablein the problem catalogue (errors.go:74,117-119) but not answered today: OpenReturnReceipt never looks the RMA up and moves no RMA (apis/openapi.yaml, operation openReturnReceipt), so opening a receipt against any rmaId is accepted
line-already-inspected / inspected-exceeds-receivedgrading rules (ADR 0002)
override-reason-requiredan override must explain itself
concurrent-modificationoptimistic version guard lost — reload, re-apply
policy-version-exists (409)PUT /disposition-policies/{version} for a version that is already declared; the policy is append-only and nothing changed — declare the table as a NEW version
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.