Skip to main content

Troubleshooting

The BFF is a stateless edge over six REST services: it has no database, no Kafka and no queue, so every failure is either a boot error, a refusal at the edge (4xx), or an upstream that is slow, down or unhappy (5xx). Every error the edge itself produces is application/problem+json with a type under /problems/ (internal/adapters/inbound/http/problems.go). An upstream's own answer (including its problem body and status) is relayed untouched, so first decide whose problem it is: the type starts with /problems/ and is in the table below, or it is the upstream's.

Tools you will use: the JSON log (http request records with route, status, request_id, trace_id), the trace (one server span plus one client span per upstream call), and LOG_LEVEL=debug. See Observability.

Boot and liveness​

SymptomCauseCheckFix
Pod in CrashLoopBackOff, last log storefront-bff stopped with invalid configuration: ... is requiredOne or more of the six *_URL variables is unset or blank; all problems are listed togetherkubectl -n storefront-bff logs deploy/storefront-bffSet config.productDiscoveryUrl, deliveryPromiseUrl, shoppingCartUrl, checkoutUrl, customerOrderingUrl, pricingUrl (Configuration)
storefront-bff stopped with base URL of <service> is missing or not an absolute http(s) URLThe variable is set but has no scheme or host (product-discovery:80, a bare host)The message names the serviceUse http://host[:port] or https://...
invalid configuration: BUDGET_QUERY_MS must be a positive number of milliseconds (or _COMMAND_, _CONFIRM_)Non-numeric, zero or negative budgetThe variable value in the DeploymentFix the value or unset it for the default
invalid configuration: COOKIE_SECURE must be a booleanValue strconv.ParseBool rejects (yes, on)SameUse true/false/1/0
storefront-bff stopped with listen: ... address already in usePORT is taken, or two processes run locallylsof -i :8080Change PORT (the chart keeps it equal to service.targetPort)
Pod is Ready and /readyz is 200 but requests failReadiness is a static handler and does not probe the upstreamsGET /products and look for 503/504Fix the upstream; the pod does not need a restart
Pod killed at rollout with requests lostIn-flight requests get 20 s after SIGTERM; a confirm may need up to 15 sPod terminationGracePeriodSeconds vs config.shutdownDrainDelayKeep the grace period above drain delay plus 20 s

Problems the edge produces​

Status and typeCauseCheckFix
400 /problems/malformed-requestA NUL character (%00, \u0000) in the query string or body, or the body could not be readThe detail says whichStrip the NUL on the client
404 /problems/resource-not-foundNo route matches, or a NUL in the path. The edge routes only the paths in the API reference; :verb suffixes are part of the path (/orders/{id}/cancellations)Compare the path with the endpoint table; the log line has route=unmatchedFix the URL. An upstream 404 for a real route (unknown product, cart, order) is the upstream's body, not this one
405 method-not-allowedRight path, wrong verb (for example GET /checkout/{id}/confirmations)Table in the API referenceUse the documented verb
413 /problems/payload-too-largeBody above 1 MiBContent-LengthSend less; nothing in the storefront legitimately needs 1 MiB
422 /problems/validation-failedThe edge refused the request before calling anyone. detail is a fixed sentence, never request data: malformed id ([A-Za-z0-9._-], 1 to 128 chars, alphanumeric first), unknown JSON field, missing postalPrefix, reason empty or over 200 chars, e-mail over 254 chars, paymentMethodToken empty, over 256 chars or card-shapedRead detail; bodies are strict (DisallowUnknownFields) so a stray field failsSend exactly the documented body
422 with detail card data is refused; send the payment method token only or paymentMethodToken must be a PSP token, never a card numberThe confirm body has a card-shaped key (pan, cvc, expiry, ...) or the token is a 13 to 19 digit number passing the Luhn checkThe client sends raw card dataTokenise at the PSP first and send only the token. This guard is intentional and must not be relaxed
422 /problems/session-requiredThe route needs the shopper (open checkout, /me, /me/addresses, /orders without shopperId) and the cookie carries noneIs the sf_state cookie sent? See the cookie row belowRegister or log in first; send the cookie
499 /problems/client-closed-requestThe caller went away before the answer; the edge does not retryUsually a browser navigation or a short client timeoutNone; if frequent, a client timeout is below the route budget
503 /problems/upstream-unavailableThe upstream refused or dropped the connection, DNS failed, the reply was over 4 MiB, the reply could not be read, or (order detail, delivery dates) a 2xx body was not the JSON the composition needsThe problem body does not name the service (it never carries upstream data). Open the trace: the failing client span is the culprit; with LOG_LEVEL=debug read the SDK errorsFix the upstream or its URL. Retrying with the same Idempotency-Key is safe (see below)
504 /problems/gateway-timeoutThe whole-request budget expired: 2 s (query), 5 s (command), 15 s (confirm) by default. Budgets are never retriedTrace: which client span is longFix the slow upstream first; raise BUDGET_*_MS only when the upstream is legitimately slower
500 /problems/internal-errorA handler panic (handler panic ERROR log, value deliberately not logged) or a JSON marshal failureThe ERROR log line has method and pathReport with request_id
500 /problems/route-not-allowedA call the allowlist refused (ErrRouteNotAllowed): a code change added an upstream route without allowlisting it. Not a client error, so it stays a 5xxThe ERROR log line has method and path; the upstream service is in the wrapped error, not in the responseReport with request_id; add the route to internal/domain/composition/allowlist.go and its test
SymptomCauseCheckFix
session-required right after a successful login or register, with curlThe cookie is Secure by default, and curl will not send a Secure cookie over plain http://curl -i shows Set-Cookie: sf_state=...; SecureFor plain-HTTP runs set COOKIE_SECURE=false (the chart already does by default). Through Kong over HTTPS keep it true
The browser keeps no cookie, or sends none to some pathsThe cookie is scoped to Path=/api/storefront; calls made to the bare paths (/carts, no prefix) are outside itThe Path in Set-CookieCall through the /api/storefront prefix; the BFF accepts it with or without
A corrupted or hand-edited cookie behaves like no cookieDecodeState drops malformed values and ids failing ValidID; it never errorsDecode the value: c=<cart>&s=<shopper>&k=<checkout>Log in again. Do not look for an error; there is none
The cart is gone after logging in as someone elsePOST /sessions replaces the shopper in the cookie, not the cartCookie c=Create a new cart; carts are listed with GET /carts?shopperId=
A double click creates two carts, lines or ordersThe page sent a fresh Idempotency-Key per click instead of one per user submitCompare the Idempotency-Key in the upstream's log, sf- plus 40 hex charsHave the page mint one crypto.randomUUID() per submit and reuse it on retry
400 /problems/idempotency-key-requiredA POST or PATCH without Idempotency-KeyThe request headersSend the header (1 to 128 visible ASCII characters)
409 /problems/idempotency-key-reusedThe same Idempotency-Key was re-sent with a different body; the provider answers it and the BFF relays itBy designMint a new key per distinct action
A 202 from checkout confirmThe payment outcome is in doubt; the upstream placed or will place the orderGET /checkout/{id} until it settlesPoll, do not re-post with a new Idempotency-Key; re-posting the same one is safe

Composed routes that degrade​

SymptomCauseCheckFix
GET /orders/{id} has no trackingThe tracking leg failed or was not 2xx; it is optional and only visible as a failed child spanTrace: /orders/{id}/tracking client spanFix customer-ordering tracking; nothing to do at the edge
GET /orders/{id} has no totalsTotals are joined only when the cookie's last checkout session placed this order and that read succeededCookie k=; GET /checkout/{k} returns the same orderIdExpected for an order placed on another device or after the cookie changed
POST /products/{id}/delivery-date-quotes returns tiers without chargeThe pricing schedule read failed; only the charge is droppedTrace: /delivery-charge-schedules/current client spanFix pricing. The quote itself is required: if delivery-promise fails the whole call is 503 or the upstream's own status
delivery-dates returns an empty tiers listOnly offers in state QUOTED are listed; the rest are in unavailableThe unavailable arrayThe network cannot serve that prefix and product
delivery-dates is 422 for a valid-looking prefixpostalPrefix is 1 to 10 letters, digits, spaces or dashes, never an addressdetailSend a prefix
Dates read one day off on the pageThe window carries the destination's IANA timeZone as quoted (ADR 0005); the BFF never converts. No timeZone means UTCThe timeZone fieldConvert on the page using that zone
GET /categories is stale or flatThe BFF relays the category tree unchanged (ADR 0004)Call product-discovery directlyFix at product-discovery
An unknown query parameter has no effect on GET /productsOnly q, categoryId, inStock, priceMin, priceMax, sort, after, limit are forwardedsearchParams in usecases/catalog.goUse the listed filters

No telemetry​

SymptomCauseCheckFix
No traces or metrics for storefront-bffCollector unreachable or OTEL_EXPORTER_OTLP_ENDPOINT wrong; export drops silentlyStart with LOG_LEVEL=debug: exporter failures log as opentelemetry errorPoint the variable at the Collector (otel.endpoint in the chart); the edge keeps serving meanwhile
Metrics under an unexpected service_nameOTEL_SERVICE_NAME overriddentelemetry configured log line shows service_nameUnset it
No access-log line for /healthzThe logger skips probes on purposeNoneExpected

When it is not the BFF​

If the problem body has a type that is not under /problems/ and a status the table does not list, the upstream answered it. Take the request_id or trace_id, find the matching client span, and continue in that service's runbook. The BFF never rewrites an upstream status, so a 409 or 422 from checkout reaches the browser exactly as checkout sent it.