A 200 That Means No: The API Failure Mode Nobody Files a Bug For

Every API has a failure mode its authors never see, because from the inside it doesn't

look like a failure at all. It returns 200 OK. The body parses. The schema validates.

And somewhere downstream a developer spends forty minutes debugging a request that was

refused before it ever ran.

I shipped one of these. Then I integrated against it and it caught me — my own API,

my own error handling, forty minutes gone. That's what convinced me it's worth writing

down as a pattern rather than a bug report.

The shape

Here's a real refusal, from an image generation endpoint that meters anonymous usage:

{"code": 0, "message": "ok", "data": {
  "wall": true, "reason": "anon_credits", "cost": 5, "remaining": 0
}}

Status code: 200. Application code: 0. Message: "ok". The only thing indicating

that nothing happened is data.wall, four levels into the payload.

Now here's the client code that every developer writes, including me:

resp = requests.post(url, json=payload)
resp.raise_for_status()          # passes — it's a 200
task_id = resp.json()["data"]["id"]   # KeyError

The error that surfaces is about a missing task id. So you go looking for a task id. You

check your request shape, your field names, your endpoint URL, your auth. You do not go

looking for a refusal, because nothing in the response suggested you were refused.

Why this happens (it's rarely stupidity)

Three reasons, all of them locally reasonable:

1. The framework made it easy. If your handler returns a serialised result object,

the happy path and the refusal path both flow through the same serialiser. Emitting a

non-2xx means reaching outside that flow. One is three lines, the other is one.

2. Someone was afraid of alarms. A 402 or a 429 shows up in error dashboards, gets

counted as an incident, wakes somebody up. A refusal that's expected — quota exhausted,

free tier used up — doesn't feel like an error to the team shipping it, so they file it

under "normal" and the status code follows the feeling.

3. A client somewhere broke on the correct code. This one is the most insidious.

Someone's SDK crashed on a 429, so the fix was to stop sending 429s. The blast radius

moved from one visible break to every future integrator's silent one.

None of these are dumb decisions. They're all locally cheap and globally expensive.

Why it's worse than a normal bug

A normal bug produces a complaint. This one doesn't, and that's the actual cost.

Developers file bugs against things that look broken. Nobody files a bug against ok.

They assume they're holding it wrong — which, from the evidence available to them, is

the reasonable inference. So the feedback loop that would tell you about it never

closes. You get to keep the design because it never generates the signal that would

make you reconsider it.

Measure it in the only currency that matters: **how long does it take a competent

stranger to find out they were refused?** With a 429 and a Retry-After header, about

four seconds. With a 200 and a boolean, as long as it takes them to give up and print

the raw response.

The same shape shows up in two more places

Once you know to look for it, the pattern isn't limited to status codes. Two others

from the same integration:

An error that describes the symptom, not the cause. Pass an image under the wrong

field name and the response says a reference image is required for this edit. You did

pass one. The message describes the server's state after ignoring your field, which sends

you off checking whether your image URL is reachable — when the real problem is that the

field was never read. A message naming the expected field (options.image_input) turns

forty minutes into four seconds.

A state machine that isn't monotonic. I watched a job status go

processing → pending → success. It went backwards. Any poll loop written as

"anything other than processing means we're done" exits early and reports success with

no result. The fix is to document your terminal states explicitly — and if your states

can move backwards, say so loudly, because every consumer will assume they can't.

All three share one property: the failure is shaped like a success. That's the

family resemblance, and it's the thing worth naming.

What to do instead

For anyone designing an API surface right now:

  • Refusals get non-2xx codes. Quota exhausted is 402 or 429. Rejected input is

400 or 422. Yes, it will show up in your dashboards. That is the point — you're

moving the cost from your integrators onto your own monitoring, where somebody is

actually paid to look at it.

  • Name the cause, not the symptom. a reference image is required describes what

the server observed. options.image_input is required for scene=image-to-image

describes what to change. Same length. Wildly different value.

  • Document terminal states, and any non-monotonic transitions. If you can't promise

monotonic status, say so on the page where people learn to poll.

  • **Then integrate against your own API using a language and HTTP client you don't

normally use.** The one thing that would have caught all three of these is exactly the

thing nobody schedules: being your own confused first-time user, without the mental

model that makes the confusion invisible.

The self-serving footnote

The refusals I quoted are from the free tier of an image API I work on

(Kavel). They're now

documented rather than quietly returning ok, which is the least I could do after

losing an afternoon to my own design.

If you want to see the shape yourself, the anonymous tier is callable with no API key —

you generate your own identifier string and send it as a header. Run it until the credits

run out and you'll get exactly the response quoted at the top of this post. There are

worse ways to internalise a lesson than watching an API tell you "ok" while doing

nothing at all.

The image tools run

in the browser too, if you'd rather not write a client just to see an error.

Single-edit pages to try in the browser

评论