DEV Community

Liudas
Liudas

Posted on

When Your API Lies: 404 That Returns 200 OK

Some APIs don’t break loudly. They break politely. You hit an endpoint that doesn’t exist — and instead of a clean, respectable 404 Not Found, you get a cheerful 200 OK.

Fantastic. Everything is fine. Except it isn’t.

In this case, Rentgen took a perfectly valid request and simply appended random garbage to the URL path — something that absolutely should not exist. The expected behavior was obvious: return 404. What came back? 200 OK. Green lights everywhere. Reality nowhere.

This is not a cosmetic issue. When a non-existent endpoint returns 200, your API is effectively lying. Developers debug headers. They inspect payloads. They question auth. They blame the frontend. Meanwhile the real problem — “this path doesn’t exist” — is completely hidden.

At scale, this gets worse. Monitoring dashboards show healthy traffic. No error spikes. No alerts. And yet integrations fail, mobile apps behave strangely, and partners open support tickets. The system looks stable because it refuses to admit mistakes.

Most of the time this isn’t malicious. It’s lazy routing. Catch-all handlers. Gateway rewrites. “Temporary” patches that became permanent. Over time the API forgets how to say no.

APIs are contracts. If a resource does not exist, the only honest answer is 404 Not Found. Not maybe. Not sometimes. Always.

Rentgen checks this because boring protocol behavior is where expensive bugs hide. It deliberately generates invalid paths to see whether your API still tells the truth when something isn’t there.

A correct 404 won’t impress anyone in a demo. But it will save you hours of pointless debugging and protect the integrity of your monitoring.

Full breakdown here:
👉 https://rentgen.io/api-stories/404-not-found-handling.html

Top comments (0)