Yeah, if you start pushing error semantics into the next layer down, then why not send ICMP AdPro along with a 403? The apps should stay in their lane and let layer 5 do its job
Additionally, if you want to stay true to the original protocol design philosophy of the internet, you're not supposed to intermingle different protocol layers. Maybe there's a time where you want to run the API on top of websockets.
I shit you not that multiple leaders have raised issues with our team about why our service "has so many errors" when we send correct 404 and 403 responses back to clients asking for things that don't exist or they don't have access to. They'd like to know why they shouldn't be changed to 200s so that there are "fewer errors."
Would this effectively be the same as 404/403? Just with extra steps? Whatever automation is scanning would just need to be adjusted for such a format?
That's correct. if the error codes in the 200 aren't different, then it's just 403/404 with extra steps. That being said, you can just use 404 for all 403 cases to neutralize enumeration attempts.
I have been told the exact opposite. 404 for everything a user doesn’t have access to. The reason was, the person doesn’t know if it’s because of access or because it doesn’t exist.
Default values are always good, but not neccesarily what the customer wants.
For example, retroactive changes. Sometimes it is OK, sometimes it is not allowed. The logic when is not duplicated into the frontend (would be double-maintenance) so there is a check call first.
Or another classic, there just is no change to existing data.
Well you still want to track 4xx errors. For example if there's a deployment, and suddenly 100% of your API responses return 403 the deployment should be rolled back, same as if it went to 0 suddenly.
Similar to benchmarks when some higher-up says that the numbers aren’t high enough and we should change the suite to make it look good before showcasing.
Here is how I would answer that question from the leadership team:
"Lying about numbers removes valuable information. It's like excluding all expenses from the company's quarterly report. Our numbers would look great, but we'd lose valuable information that we need to run the business."
I encountered an API that sent JSON UNLESS there was an error, in which case it sent an HTML response. Good luck finding where in that soup it says what's wrong.
I guess he meant that the query returns empty. I've seen the same in a big latin American bank. You use some filters returns 200, other filters, 404. We had to build the same shit decoder...
Well, we know that the URL is correct. Usually, a 404 is just a short hiccup or caused by a container restart. That's why we have a retry mechanism that waits for about a minute and tries again. After a few retries it's send to an error queue.
You can't have a successful login with an incorrect password. Or rather, you shouldn't, and if you do, you need to go stand in the corner and thing about what you/your AI have/has done.
I stopped laughing at this API design after a url misconfiguration led to us receiving 404 and erroneously treating it as confirmation of a missing transaction
And yet half the systems I interact with won't read the object on the return unless it has a 200. I need that 200 and I also need you to put "Success" in the body just like that or else this dumb system will think it failed and throw an error to the end user.
Yes, I agree it's dumb. I didn't design it. Don't make me defend it.
That's the biggest issue with using non-200 codes. So many platforms treat this as an exception rather that you have to catch rather than following the regular code path where you can just check the status code.
Needing to handle stuff in an exception just because the record didn't exist which causes a 404 on some systems is just annoying.
Also, 404 meaning record doesn't exist and endpoint is completely wrong is pretty annoying as well.
Not me getting a 404 on a coding take-home project on a fake backend when asking for some db entry and after 30 minutes of trying to figure out why my postman can’t reach it, it dawned on me that nothing is wrong. The backend sent me 404 to tell me it couldn’t find the entry…
I thought I am going to throw my monitor out the window 😭
The HTTP status codes aren't really diverse enough to explain all the different errors, so just returning 200 and then having the client check the payload for the error code and message makes more sense.
The thing here is pretty simple, standards like HTTP status codes are made so everybody can expect the same thing, create software accordingly, and reuse It.
If you are a backend developer every opinionated framework out there is using these default HTTP status codes for errors without you handling It.
The funny thing is if you are a frontend developer, lets say a mobile one using a type-safe language your libraries out there for some special reason let you parse the 200-299 status responses specifying a type, but not for the errors, so you have to make a custom adapter for errors that dont use the automatic parsing.
Since a lot of APIs are just an abstraction of the data source and many only serve one or a few client apps from the same company is reasonable to make things easy and using a non standard approach like having errors inside the 2XX responses.
I've decided to use both approaches at the same time since already existing apps were already using the 200 approach, our APIs use the standard status codes and Problem details (RFC 9457 standard) as default and I've made an extensive standard for our enterprise that you can expect changing the content type header so everyone can use what is easier to implement without loosing functionality.
API to API or some webs probably preffer problem details, mobile apps our standard, we have libraries for both, external clients benefict from this too.
I have noticed vibe coders only produce code thay never errors. print error this print error that. HoW Tf Am I sUpPoSeD tO kNoW tHeRe Is SoMeThInG wRoNg GoInG oN
Dude fuck this. I have an API I work with that just responds 200 to everything. To know it failed you have to inspect the json, but it's not standardized across functions. So your real response could be anywhere in there. I have a map table to handle error checking for different endpoints.
We have a third party integration that returns errors and warnings as 200 responses. If it's one error, it includes an "error" property with a string. If it's multiple, it's an "errors" object where each error is a new named property of that object. If it's a warning, it's a "warning" object with the warning as a named property. Three entirely different formats. All string equality checks. Writing a parser for that suuuucked.
665
u/NullOfSpace Sep 22 '26
The server is successfully serving you an error message.
342
u/Dull_Caterpillar_642 Sep 22 '26
I shit you not that multiple leaders have raised issues with our team about why our service "has so many errors" when we send correct 404 and 403 responses back to clients asking for things that don't exist or they don't have access to. They'd like to know why they shouldn't be changed to 200s so that there are "fewer errors."
62
u/DDFoster96 Sep 22 '26
I encountered an API that sent JSON UNLESS there was an error, in which case it sent an HTML response. Good luck finding where in that soup it says what's wrong.
76
u/Mr_Tottles Sep 22 '26
Unironically there is a team at my workplace that does this and it’s impossible to interact with their API
47
u/SadEngineer6984 Sep 22 '26
GraphQL people will say this is normal
14
u/StarboardChaos Sep 22 '26
That's a transport problem. When you move away from HTTP, then you don't have a status code problem.
Status codes made sense when you return files. Then you need them to tell the full story. When dealing with APIs, they can tell you the story.
There was also the idea of HATEOAS, which is a footnote in the textbook nowadays.
33
u/hpyfox Sep 22 '26
"That's right! It goes in the square hole."
16
u/sump_daddy Sep 22 '26
API errors and JSON Name/value pairs,
name: name a more iconic duo: more iconic duo
15
u/thunderbird89 Sep 22 '26
You can't have a successful login with an incorrect password.
Or rather, you shouldn't, and if you do, you need to go stand in the corner and thing about what you/your AI have/has done.
11
u/shnutzer Sep 22 '26
I stopped laughing at this API design after a url misconfiguration led to us receiving 404 and erroneously treating it as confirmation of a missing transaction
5
u/LogicBalm Sep 22 '26
And yet half the systems I interact with won't read the object on the return unless it has a 200. I need that 200 and I also need you to put "Success" in the body just like that or else this dumb system will think it failed and throw an error to the end user.
Yes, I agree it's dumb. I didn't design it. Don't make me defend it.
5
u/EdelWhite Sep 22 '26
I'm the complete opposite. I think there's not enough status codes, they're all useful.
3
u/billyowo Sep 23 '26
in my first job, there is only 200 or 500. data not found? 500. bad formatted request? 500. not authenticated? 500.
3
u/BorderKeeper Sep 23 '26
Not me getting a 404 on a coding take-home project on a fake backend when asking for some db entry and after 30 minutes of trying to figure out why my postman can’t reach it, it dawned on me that nothing is wrong. The backend sent me 404 to tell me it couldn’t find the entry…
I thought I am going to throw my monitor out the window 😭
6
u/HanSolo71 Sep 22 '26
Fucking slack returns a 200 and then has a sub property called "OK" that let's you know if it failed. The fuck is this.
9
u/w1n5t0nM1k3y Sep 22 '26
The HTTP status codes aren't really diverse enough to explain all the different errors, so just returning 200 and then having the client check the payload for the error code and message makes more sense.
4
u/Few_Move_4594 Sep 22 '26
Did you make this meme after my response to a meme about everything being POSTs?
2
u/mlody11 Sep 22 '26
failed successfully.
2
u/Own_Natural_6803 Sep 22 '26
Success: the sever you're attempting to request has been down since 2015
2
u/williamjseim Sep 23 '26
Confuse the enemy and only have delete end points and only return teapot
5
u/krojew Sep 22 '26
Make fun all you want, but an error array in a 200 response is idiomatic graphql for good reasons.
2
u/Gilga89 Sep 22 '26
The thing here is pretty simple, standards like HTTP status codes are made so everybody can expect the same thing, create software accordingly, and reuse It.
If you are a backend developer every opinionated framework out there is using these default HTTP status codes for errors without you handling It.
The funny thing is if you are a frontend developer, lets say a mobile one using a type-safe language your libraries out there for some special reason let you parse the 200-299 status responses specifying a type, but not for the errors, so you have to make a custom adapter for errors that dont use the automatic parsing.
Since a lot of APIs are just an abstraction of the data source and many only serve one or a few client apps from the same company is reasonable to make things easy and using a non standard approach like having errors inside the 2XX responses.
I've decided to use both approaches at the same time since already existing apps were already using the 200 approach, our APIs use the standard status codes and Problem details (RFC 9457 standard) as default and I've made an extensive standard for our enterprise that you can expect changing the content type header so everyone can use what is easier to implement without loosing functionality.
API to API or some webs probably preffer problem details, mobile apps our standard, we have libraries for both, external clients benefict from this too.
1
u/Random_-account Sep 22 '26
200 IQ
1
u/MarinaEnna Sep 22 '26
I have noticed vibe coders only produce code thay never errors. print error this print error that. HoW Tf Am I sUpPoSeD tO kNoW tHeRe Is SoMeThInG wRoNg GoInG oN
1
u/bonanochip Sep 23 '26
People going to stuff passwords can be tricked by not knowing that the password is incorrect. But the user can be recommended to try again with tips.
1
u/razin_the_furious Sep 23 '26
Stop making memes about my company’s API!
1
u/lorddrake4444 Sep 23 '26
If you do this seek help
1
u/cwmckenz Sep 23 '26
Task failed successfully
1
u/mdgv Sep 23 '26
I'd say that the HTTP server and your "application" server could be seen as different things. On the other hand, what are HTTP codes for...
1
u/ComradePruski Sep 23 '26
AWS API be like:
1
u/Jlove7714 Sep 24 '26
Dude fuck this. I have an API I work with that just responds 200 to everything. To know it failed you have to inspect the json, but it's not standardized across functions. So your real response could be anywhere in there. I have a map table to handle error checking for different endpoints.
1
u/Luudrian Sep 28 '26
We had a client API returning 200 with a json blob that said "Login failed" (basically)
Took us awhile to figure that one out. Everyone saw "200" and was like "OK!", It wasn't until someone looked at the actual message...
1
u/glha Oct 09 '26
Stop the harassment, people need the extra info from the JSON.
1
u/Kavrae Sep 22 '26
We have a third party integration that returns errors and warnings as 200 responses. If it's one error, it includes an "error" property with a string. If it's multiple, it's an "errors" object where each error is a new named property of that object. If it's a warning, it's a "warning" object with the warning as a named property. Three entirely different formats. All string equality checks. Writing a parser for that suuuucked.
1
u/the_unexpected_nil Sep 23 '26
The http error codes are protocol level codes and misusing them to also indicate application level errors can make things difficult.
Interestingly grpc enforces this by always using http success codes and then sending an app level status. From a strict set of limited statuses ...
0
u/Water1498 Sep 22 '26 edited Sep 22 '26
I just realized I'm actually doing it accidently in one of my cases. The good news, its adding a single line and regression test.
0
u/YeastyWingedGiglet Sep 22 '26
How many different versions of this meme is going to get posted lol
0
u/reckless24601 Sep 23 '26
Tomorrow is my turn to repost this
0
u/Mattallurgy Sep 23 '26
Unironically, this is how the multi-billion dollar fortune 200 company I work for handles API responses because “it’s what the customers expect”
0
u/dethswatch Sep 23 '26
you laugh, but I was told to 200 with error field at <enormous org> and started considering my options
0
u/FurySh0ck Sep 23 '26
Pentester here and honestly? This is actually a more secured approach, very annoying though
0
u/EirIroh Sep 23 '26
My short experience interacting with APIs, summarised:
Case 1: ”Your request was processed successfully, but there was no matches to your query – here’s an empty JSON.”
Case 2: ”You have made too many API calls in a short amount of time, so you’re being rate limited – here’s an empty JSON.”
Both cases returning 200 codes sure made the task awkward.