Q&A-21Review a spec that uses 200 for every response.
Answer
Stance. Treat this as a protocol bug, not a style preference. The status line is the only field every intermediary (CDN, gateway, service mesh, generated SDK, retry library, dashboard) parses without knowing your schema. Overloading 200 deletes that signal. Before approving the spec I'd want three answers: public or internal, are there shipped consumers, and what sits in front of it (shared cache, API gateway, generated clients)? Those decide whether you fix it in place or version it.
The mapping.
| Outcome | Status | Notes |
|---|---|---|
| GET success | 200 | |
| POST created | 201 | plus Location |
| Accepted, async | 202 | |
| DELETE, no body | 204 | |
| Malformed syntax | 400 | |
| Missing/invalid credentials | 401 | plus WWW-Authenticate |
| Authenticated, not allowed | 403 | |
| Unknown resource | 404 | |
| Wrong method | 405 | plus Allow |
| State conflict | 409 | |
| Precondition | 412 / 428 | |
| Semantic validation | 422 | |
| Rate limited | 429 | plus Retry-After |
| Upstream failure | 502 / 503 / 504 | |
| Unhandled | 500 |
Domain detail belongs in the body as RFC 9457 problem details: application/problem+json with type, title, status, detail, instance. The status member must equal the status line: a mismatch is its own bug.
Why it breaks: the mechanism.
Caching. RFC 9110 §15.1 lists 200 as heuristically cacheable. A shared cache may store a 200 that carries no explicit freshness and reuse it. Trace: client A sends GET /orders/42 with an expired token; the server replies 200 with {"error":"token_expired"} and no Cache-Control. The cache stores it. Client B, a different user with a valid token, requests the same URL and is served A's error body as a fresh 200. 401 is not heuristically cacheable, so the correct status would have prevented this outright. Fix: correct statuses plus Cache-Control: no-store on error responses.
Retry. Retry middleware keys on status. A POST /payments returning 200 {"status":"failed","retryable":true} is never retried by a client that retries on 5xx/429: the payment is silently dropped. Invert the middleware to retry on 200-with-error and you replay a non-idempotent POST; without an Idempotency-Key you double-charge. 429 with Retry-After is the one case where the status line tells the client exactly what to do.
Circuit breaking. Envoy outlier detection and most mesh breakers eject hosts on consecutive 5xx. All-200 means a dead dependency keeps taking traffic.
Monitoring. SLO burn-rate alerts, APM error rates and gateway dashboards all classify on status. Everything is 200, so the error budget never burns and nothing pages.
Generated clients. OpenAPI-generated clients throw typed exceptions on non-2xx. With all-200 every caller hand-parses the body and the error taxonomy leaves the type system.
Failure modes and how you'd catch them.
- Cross-user error served from cache: send a synthetic request with a bad token, then one with a good token, and assert the second isn't the first's body; watch cache hit ratio on error paths.
- Silent payment drop: count
Idempotency-Keyduplicates and compare accepted against attempted POSTs. - Undetected outage: alert on divergence between the 200 rate and the error field inside the body. That divergence is the migration's own smoke alarm.
- Breaker never trips: confirm Envoy's
outlier_detection.ejections_enforced_totalis non-zero during a known dependency failure.
Migration. If consumers already parse the envelope, don't flip statuses under them. Negotiate: serve the old shape on the existing media type or path, the corrected one on a new version, log which clients use which, and set a deprecation date. Canary it and watch the divergence metric above.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.