If you return a 200 OK for any kind of error to my API requests, I will come to your house and mortally wound you and then tell everybody you know that you're perfectly fine.
I had a nightmare dealing with a reverse proxy that would return 200 OK on its error page if the destination server was down.
Becomes incredibly annoying when the status_code and detail fields aren't in the successful response, so you don't even know about it thanks to no documentation.
Yeah, if only there were some part of the HTTP specification itself that returned a well-defined and commonly-known numeric status code in a standard location, preferably one that everyone knows about and can easily check for with already-implemented validation routines...
This is literally happened to me today, but besides not sending a 400/500 status api returns a field “result” that is in case of success is an object, but in case of failure an array with a single error string inside. Also it accepts an array with a single object inside it. I hope the guys developed it will integrate with the similar apis till the end of their carrier days.
I shouldn't have to validate on a variable that may or may not be there. Believe it or not that's the point of the status code, people need to learn to use it
I had a back-end developer in the team who would always return 500 for any kind of errors.
I said: "This is where my payload was wrong and the server should let me know by returning a 400. I get 500 instead." Her: "But it's a server error. It's correct."
There's a (joke) proposal for a 7xx series of codes which would translate, roughly, to "I fucked up but much deeper" that I've been aching to find an excuse to use
7
u/polish_jerry Nov 03 '20
Those fucking php devs
55
u/[deleted] Nov 03 '20 edited Nov 03 '20
If you return a 200 OK for any kind of error to my API requests, I will come to your house and mortally wound you and then tell everybody you know that you're perfectly fine.
I had a nightmare dealing with a reverse proxy that would return 200 OK on its error page if the destination server was down.
53
u/shaliozero Nov 03 '20
Becomes incredibly annoying when the status_code and detail fields aren't in the successful response, so you don't even know about it thanks to no documentation.
11
u/EsorX Nov 03 '20
And just like that request done
*happy evil backend people noises *
11
u/vlad_tkachenko Nov 03 '20
This is literally happened to me today, but besides not sending a 400/500 status api returns a field “result” that is in case of success is an object, but in case of failure an array with a single error string inside. Also it accepts an array with a single object inside it. I hope the guys developed it will integrate with the similar apis till the end of their carrier days.
7
u/aeroverra Nov 03 '20
I shouldn't have to validate on a variable that may or may not be there. Believe it or not that's the point of the status code, people need to learn to use it
3
u/cybermage Nov 03 '20
HTTP status codes and API status codes are two different concerns is a hill I’m willing to die on.
3
u/powerhcm8 Nov 04 '20
Reminds me of when I didn't even returned status code, I only returned a success false and a message
2
u/Dummerchen1933 Nov 03 '20
We are all guilty of this
-7
u/acylase Nov 03 '20
I hate restful api
0
u/[deleted] Nov 03 '20
[deleted] — view deleted comment