Skip to main content

Troubleshooting

Each entry reads symptom, cause, check, fix. Log message texts are the ones the code writes; see Observability for the full list. The operational procedures behind the fixes are in the Runbook. Commands assume the local kind cluster namespace warehouse-systems.

The process does not start​

SymptomCauseCheckFix
Exit 1 at once, log service exited with error naming a variableA mandatory variable is missing or invalid. loadConfig validates everything before anything is opened (cmd/api/config.go)kubectl -n warehouse-systems logs deploy/shipping-and-tracking --previous. Messages: DATABASE_URL is required, KAFKA_BROKERS is required, <X>_CONSUMER_GROUP is required, SHIP_TO_ENCRYPTION_KEY is required, STOP_KEY_SECRET is required, CUSTOMER_ORDERING_URL is requiredSet the variable in the Secret or ConfigMap and restart. Values are never echoed
SHIP_TO_ENCRYPTION_KEY: bad key: want 32 bytes, got N or not base64The key is not base64 of exactly 32 bytesdecode the Secret value with base64 -d and count the bytes: it must be 32Generate a new key (openssl rand -base64 32). Existing snapshots sealed with the old key are no longer openable (nothing reads them back; they are purged 30 days after the journey closes)
STOP_KEY_SECRET: ...The secret is shorter than 16 byteslength of the Secret valueUse at least 16 bytes. Changing it changes the stopKey of labels issued afterwards; issued labels keep theirs
EVENT_PUBLISHER=log is not supported or unknown valueThe deployment sets a publisher this service does not havekubectl get cm for the envSet kafka or remove the variable. The chart refuses the render as well
CUSTOMER_ORDERING_URL "..." is not an absolute http(s) URLMissing scheme or hostthe ConfigMap valueUse http://customer-ordering.warehouse-systems.svc.cluster.local:80 style URLs
CUSTOMER_ORDERING_TIMEOUT: "x" is not a positive durationMalformed timeout (the only duration that is a boot error)the valueUse 3s or 3
cmd/a2a exits with A2A_AGENT_URL is required or is not an absolute http(s) URLThe Agent Card must advertise a dialable URLthe pod envSet a2a.agentUrl, or leave it empty so the chart renders the in-cluster Service URL
Pod stays not started, log retrying with op="run migrations" or "ping postgres"Postgres, or PgBouncer, is not answering yet; boot retries with backoff then gives up (internal/bootretry)kubectl logs for the err field; check the database SecretFix connectivity. If DATABASE_URL goes through PgBouncer, give MIGRATIONS_DATABASE_URL a direct DSN, otherwise the migration advisory lock fails
The chart renders nothing or refusesA required value is empty, terminationGracePeriodSeconds is not above 30 s plus the drain delay, or extraEnv sets a variable the chart ownshelm template error text; charts/shipping-and-tracking/tests/render_test.shFix the values

The process is up but not ready​

SymptomCauseCheckFix
/readyz 503, problem dependency-unavailable naming kafkaNo broker answers a metadata request within 2 slog readiness: dependency is not ready with dependency=kafka; KAFKA_BROKERSFix the broker or the address. /healthz stays 200 and REST writes still succeed, events queue in outbox_events
/readyz 503 naming postgresPing failedsame log with dependency=postgresFix Postgres or PgBouncer. Writes fail with 500 internal-error meanwhile
/readyz 503 {"status":"not_ready"} and the pod is terminatingNormal drain: SHUTDOWN_DRAIN_DELAY after SIGTERMpod phaseNone
Pod restarts with consumer stopped, outbox relay stopped or ... stopped unexpectedly: exiting so the orchestrator restarts the serviceA consumer, a job loop or the relay returned on its own; the process exits non-zero on purpose (watchWorkers)the log line before the exit gives the cause (error field)Fix the cause; the restart itself is the recovery

REST calls​

SymptomCauseCheckFix
400 idempotency-key-required on a POSTThe Idempotency-Key header is missing (all three POSTs need it)request headersSend a unique key per logical request
400 idempotency-key-invalidKey longer than MaxIdempotencyKeyLen (128) or not printable ASCIIkey length and charactersUse a UUID
409 idempotency-key-reusedSame key, different method, path or body (the key is global; method, path and a body hash are compared)the two bodiesUse a new key for a new request. Keys expire after 24 h
A retry under the same Idempotency-Key was executed again (no Idempotency-Replayed header)The first answer was RETRYABLE (ADR 0020): validation-failed, address-suspect, pickup-point-unavailable, destination-prefix-unavailable, tracking-number-taken, concurrent-update or a 5xx follow state that can change, so nothing was stored and the key was releasedSELECT count(*) FROM idempotency_keys WHERE key = $1 is 0 after such an answerRetry with the SAME key. Only a success, a FINAL refusal (not-found, label-already-issued, void-after-handover, journey-closed, duplicate-scan) and an OUTCOME refusal (scan-out-of-order, illegal-transition, stored with its scan) are replayed
422 validation-failed from POST /labels with tier ... is not one of ..., packageNo must be between 1 and 2147483647, ... is requiredBody fails internal/adapters/inbound/http/handlers.go validation; unknown JSON fields are rejected as wellthe detail text names the fieldFix the request
422 validation-failed from POST /labels and the body is validcustomer-ordering answered 404 for the order, mapped to ports.ErrNotFound while issuing, the order is unknown to itGET {CUSTOMER_ORDERING_URL}/orders/{orderId}/ship-toIssue the label for an order that exists
503 ship-to-unavailablecustomer-ordering timed out, was unreachable, answered a status other than 200 or 404, or returned a body that is not JSON (internal/adapters/outbound/customerordering/gateway.go)counter shipping.labels.issued{outcome="rejected",reason="ship-to-unavailable"}; call the URL above from the podRecover customer-ordering or raise CUSTOMER_ORDERING_TIMEOUT. No label is stored; retrying with the same key is safe
422 validation-failed with detail ship-to ... is required, countryCode must have 2 characters or ... is longer than 200 characterscustomer-ordering answered 200 but the ship-to fails Address.Validate (internal/application/shipto/shipto.go); the detail names the field, never the valuethe response of the ship-to URLFix the order's address upstream
422 pickup-point-unavailable from POST /labelsThe order is collected at a pickup point (customer-ordering answered destinationKind: PICKUP_POINT) and the local PickupPointView does not hold that point (detail names the id only) or holds it in a state other than ACTIVE (detail ... is PROPOSED, ... is SUSPENDED or ... is RETIRED). No label is stored. Before the fix of 2026-11-18 this answered 500 internal-errorSELECT id, station_node_id, postal_prefix, state FROM pickup_points WHERE id = $1; counter shipping.labels.issued{outcome="rejected",reason="pickup-point-unavailable"}The state follows node-topology's node facts: activate the point there, or wait for its NodeRegistered / NodeActivated to be consumed (consumer lag of the group in ST_AREAS_CONSUMER_GROUP). The refusal is NOT stored under the request's Idempotency-Key (ADR 0016, addendum 2026-11-18): retry the same request with the SAME key; it is executed again each time and is served once the point is ACTIVE. A RETIRED point never becomes available again: every retry is refused
422 validation-failed from POST /labels with detail destinationPostalPrefix must be 1 to 16 characters from A-Z 0-9, a field the caller never sendsThe order is collected at an ACTIVE pickup point whose prefix in the local view is empty: a row blanked by the status fold of the versions before 2026-11-18. (A prefix with a separator cannot be the cause: node-topology registers a PICKUP_POINT only with a postal code that is wholly A-Z 0-9)SELECT id, postal_prefix, state FROM pickup_points WHERE id = $1Repairing the pickup point view
409 label-already-issuedA label already exists for (poNumber, packageNo) and this is a new idempotency key; checked before customer-ordering is calledSELECT label_ref, status FROM shipping_labels WHERE po_number = $1 AND package_no = $2Treat as success if the label is the wanted one; otherwise void it first
409 destination-prefix-unavailable from POST /return-labelsThe body names the destination by destinationNodeId and this context holds no usable prefix for that node: its NodeRegistered has not been consumed (detail the registration of node ... has not been consumed by this context), or its registered postal code has no letter or digit from A-Z 0-9 (detail the registered postal code of node ... has no letter or digit from A-Z 0-9). Checked before customer-ordering is called; no label is storedSELECT node_id, postal_prefix, updated_at FROM node_destinations WHERE node_id = $1; counter shipping.labels.issued{outcome="rejected",reason="destination-prefix-unavailable"}; lag of the ST_AREAS_CONSUMER_GROUP groupNo row: wait for the consumer to catch up, or rebuild the view if the node was registered before migration 0008 (runbook). Empty prefix: the node's postal code must be corrected in node-topology. Then retry the same request with the SAME Idempotency-Key: this refusal is not stored under the key, so the retry is executed again and answers 201 once the row has a prefix
409 tracking-number-takenThe generated tracking number collided with an existing one twice in a row (the use case retries once with a fresh number)log request failedRetry with a new key
409 concurrent-updateTwo writers changed the same aggregate; optimistic version check lostrepeated occurrences mean a hot aggregateRetry. The Kafka consumers also retry it
404 not-found on GET /journeys/{trackingNumber} or POST /labels/{ref}/voidsUnknown reference. Journey rows are created by label issuingSELECT state FROM package_journeys WHERE tracking_number = $1Check the tracking number or label reference
409 void-after-handoverThe package left the sender and the journey is still open (HANDED_OVER, IN_TRANSIT, AT_STATION or OUT_FOR_DELIVERY). A journey already DELIVERED, RETURNED, LOST or VOIDED answers journey-closed instead: the closed check comes first (internal/domain/journey/journey_close.go:82-87)journey stateA handed-over package cannot be voided
409 duplicate-scanThe scanId was already recorded for that journeySELECT * FROM journey_scans WHERE tracking_number = $1Nothing to fix, the scan is stored once
409 scan-out-of-orderThe scan is older than the last applied scan; it is stored with applied=falsethe at of the scan versus last_scan_atExpected for late data. It does not move the state
409 illegal-transitionThe scan type has no edge from the current state (see the state machine in Use cases); stored with applied=falsestate of the journeySend the intermediate scans first, or ignore
409 journey-closedThe journey is DELIVERED, RETURNED, LOST or VOIDEDjourney stateClosed journeys accept no scans, and a void of one answers journey-closed, not void-after-handover
404 not-found on POST /labels/{ref}:void or a path that matches no routeThe old colon-suffix void route is gone (ADR 0010, no alias); the void route is POST /labels/{labelRef}/voids (internal/adapters/inbound/http/server.go:25, TestRetiredRoutesAreGone)the URLCall /labels/{labelRef}/voids
422 validation-failed with a body that looks fineA NUL character (U+0000) in the query or body is rejected as a client error by rejectNUL instead of reaching Postgres; a NUL in the path is a 404the request bytesRemove the NUL

Events​

SymptomCauseCheckFix
outbox_events rows with published_at IS NULL pile upKafka unreachable, or rows parked at the attempt capSELECT count(*), max(attempts) FROM outbox_events WHERE published_at IS NULLFix Kafka. For parked rows (attempts >= OUTBOX_MAX_ATTEMPTS, log row reached the attempt cap and is excluded from future claims) run UPDATE outbox_events SET attempts = 0 WHERE id = <id> after the cause is fixed. The same event_id is republished, consumers dedupe
Label issued but downstream (for example customer-ordering) never sees LabelIssuedThe row is still in the outbox, or the relay is downSELECT event_type, published_at, last_error FROM outbox_events ORDER BY id DESC LIMIT 5 and the outbox relay log linesAs above
A consumed event has no effect and the log says skipping an event that can never be appliedThe event is valid but cannot be applied, for example an unknown tracking number or an illegal transitionthe type and event_id in the logIf the producer is wrong, fix it there. If the message must be re-driven, look in <topic>.dlq
Messages land in <topic>.dlqTransient failures exhausted the retries (log handling failed after the maximum attempts), or dead-lettering an event that can never be appliedread the dead-letter message headers for the causeFix the cause, then replay by hand; there is no automatic replay
skipping a message that is not a valid CloudEventA producer wrote a non-CloudEvents message on a consumed topicthe consumer and topic fieldsFix the producer. The offset advances
Consumer retry logs only, on an empty topicTopics are created by the first writer; if the upstream has not written yet there is nothing to readconsumer running lines with the topicUpstream gap, not a fault here
A redelivered event changes nothingNormal: processed_events holds (consumer, event_id) and the handler skips it (skipped=true in event processed)the logNone. Rows are purged after 30 days
After re-pointing a consumer group id the topic is re-read from the startA new group has no committed offsetsthe env varKeep the four group ids stable

Jobs and data​

SymptomCauseCheckFix
No PackageExceptionRaised for a journey that has gone quietThe sweep only watches journeys past LABELLED; the window depends on tier and state (6 h same-day, 24 h next-day, 48 h two-day, 72 h standard, 12 h out-for-delivery), and the sweep runs every SILENCE_SWEEP_INTERVAL (5 m)log scheduled job finished with job=silence-sweep and result=raised=N lost=N conflicts=NWait for the next tick. conflicts above zero means a concurrent update; the next pass retries
scheduled job failed; trying again on the next tickThe job's database call failedthe error fieldFix the database; the next tick retries
ship_to_snapshots rows older than 30 days after closeship-to-purge has not run or failedSELECT count(*) FROM ship_to_snapshots s JOIN package_journeys j ON j.label_ref = s.label_ref WHERE j.closed_at < now() - interval '31 days'Check the ship-to-purge job lines; HOUSEKEEPING_INTERVAL is 1 h
idempotency_keys, outbox_events or processed_events growinghousekeeping deletes keys after 24 h, relayed outbox rows after 7 days and inbox rows after 30 dayslog line idempotency_keys=N outbox_events=N processed_events=NUnrelayed outbox rows are never deleted; see the outbox entry above

MCP and A2A​

SymptomCauseCheckFix
MCP client gets a tool error for an unknown tracking numberThe tool returns the not-found problem as a tool errorthe tool resultUse an existing tracking number
A2A Agent Card advertises the wrong URLA2A_AGENT_URL points elsewhere than clients reachcurl <host>/.well-known/agent-card.jsonSet a2a.agentUrl
MCP or A2A binary works on a fresh database before cmd/api ranThey run the embedded migrations themselves; the advisory lock makes concurrent starts safeboot logNone