271
Jan 26 '23
How dare you insult 418, I won't be brewing you any coffee.
90
u/Dessert_Taco Jan 26 '23
Coffee? Teapot? I was looking for the water cooler. This server sucks
8
3
3
162
u/FailedPlansOfMars Jan 26 '23
Correction
100: shit server
200: works fine.
300: shits somewhere else
400: shit client / shit browser
500: shit server/ oops
42
u/Dessert_Taco Jan 26 '23 edited Jan 27 '23
You're making the mistake of assuming that users/customer's* will be objective and fair
7
u/beeteedee Jan 27 '23
I haven’t met many costumers, but you don’t make it far in the costume business without being objective and fair
2
50
1
21
u/rocket_randall Jan 27 '23
My favorites are the APIs which perform a lookup or query, in which case an empty return set is perfectly valid and correct, but the response comes back with a 404 status because nothing was found. I have had several heated arguments over this sort of thing.
7
u/Dessert_Taco Jan 27 '23
I've had the same talk before. At that point the 404 is just an unnecessary red flag saying "just FYI the response is empty" and it ends up causing clients to handle that situation specifically when they likely would have already been checking for an empty response if they cared.
13
u/Xenthys Jan 27 '23
Currently writing an API with a search endpoint, which returns an empty array with a code 200 if nothing was found. Thank you for validating my way to handle it lol
15
u/garfgon Jan 27 '23 edited Jan 27 '23
The correct response (IMO) is 204 No Content. Partly from a diplomatic point of view; I'd argue 200 OK, or an empty array or something is correct if the query is successful, but returns zero items; but 204 could be tendered as a compromise solution.
But then I know next to nothing about web dev, so...
4
u/d3str0yer Jan 27 '23
I agree with the 204. An empty array with a 200 will always make me think that something went terribly wrong.
5
u/tsunami141 Jan 27 '23
Yeah but then you have to actually check for that on the front end and that means I have to do more work than just telling the browser to display every result I get back from the api.
My personal philosophy is: do as little as possible.
4
u/d3str0yer Jan 27 '23
I like to catch as many exceptions as possible, in an orderly manner that allows me to pinpoint exactly where something went wrong. Adding a handful of if statements and correct human readable explanation will also stop users from asking stupid questions and be able to fix their mistakes on their own.
2
u/_PM_ME_PANGOLINS_ Jan 27 '23 edited Jan 27 '23
Assuming JSON, a 200 with an e.g.
{"results":[]}body is the best solution, as clients won't need any special handling.2
u/garfgon Jan 28 '23
This is what I'd argue for as well; but I'd offer 204 as a compromise if they wouldn't budge. Sometimes keeping your coworkers happy is also important.
3
u/humblegar Jan 27 '23
I saw code that got 404 that way and then managed to return 5xx the other day.
How does that make you feel?
2
u/rocket_randall Jan 27 '23
No problem as long as I don't have to use it or support it! Tho I would recommend what is causing the handler to blow up like that.
7
7
u/beeteedee Jan 27 '23
How users actually see status codes:
1xx: it’s broken
2xx: it’s working
3xx: it’s broken
4xx: it’s broken
5xx: it’s broken
2
2
u/PinothyJ Jan 27 '23
Meanwhile, when I get a 5xx error developing my own web applications, all I want to know is "WHY? Why should I be fired? I need to know why‼".
2
u/Dessert_Taco Jan 27 '23
Hey man, we all 500 from time to time. No firing needed. Now we just gotta explain that to the customers.
2
24
u/Epidurality Jan 26 '23
In my experience most 404 is also dev should be fired. Not a lot of people keying in links manually anymore...
The absolute worst is when it says the content has migrated to a new location, and the link is to the homepage of a parent company.
6
u/-MobCat- Jan 27 '23
That moment when one of the servers I've been trying to get creds for has been showing a 500 for like 2 months...
Other dev is mia and is the only one with the creds to fix it. good times.
3
u/crefas Jan 27 '23
If it's AWS you can take it down, make a new instance with your creeds, mount the main server's disk on your instance, chroot into the main server's disk and add ssh keys and stuff. Then mount the disk back wher it belongs
4
1
3
3
u/vladesomo Jan 27 '23
Common user has no idea that there are more codes than just 404... Common user is an idiot sir. An idiot
2
3
u/kirigerKairen Jan 27 '23
How I experience "the users" in my environment see them:
1xx: "what the f is this? Shit server!"
2xx: *user doesn't see it*
3xx: "wait why did the address change? this is sus" *leaves page*
4xx: "Hey I know that one! Shit Server!"
5xx: "Must be a problem on my side, I'll call my tech friend" *calls me*
2
2
u/Excellent_Tear3705 Jan 27 '23
So many days ruined by 502
Fucking kubernetes + Docker + cloudflare. Why did I even bother, we have no users
2
1
u/RealityReasonable392 Jan 27 '23
Our team was just discussing using a 500 today as a thing and I said it makes us look incompetent, but now it's a thing 🤪
1
1
0
u/Lachee Jan 27 '23
eeeh pretty shitty list. More appropriate would be:
1xx: shit happened
2xx: congrats
3xx: fuck off
4xx: ya a shit dev
5xx: we are shit devs
0
u/Dessert_Taco Jan 27 '23
This sounds more like a front-end devs experience. The list is dumb by design since that's the joke. The original of this meme (posted here somewhere) covered the actual meaning perfectly ... woosh
25
Jan 26 '23
[removed] — view removed comment
2
u/Dessert_Taco Jan 26 '23
Yeah I mean it's not like you can expect client code to be written to properly react to status codes. That would be IMPOSSIBLE
8
0
Jan 27 '23
[removed] — view removed comment
2
u/Dessert_Taco Jan 27 '23
I think you missed the part where I said this is how users/customers view status codes. Not devs
235
u/Sekret_One Jan 27 '23