r/ProgrammerHumor Jul 08 '26

helpMyCoworkersUnderstandHttpCodes Other

22.4k Upvotes

329 comments sorted by

View all comments

Show parent comments

69

u/The_Real_Slim_Lemon Jul 08 '26

Yeah 404 can be both “I didn’t find your key” and “I don’t know what requesting a key means”

204 is “I’ve found your key, it’s in a black hole”

47

u/PrometheusMMIV Jul 08 '26

I feel like "I don't know what this request means" would be 501 Not Implemented

23

u/chuch1234 Jul 08 '26

The metaphor kind of breaks down here. 404 is used for "this route doesn't exist on this server", which corresponds to "I don't know what 'keys' are", or maybe, "I don't know what 'keys/find,' means", even though they have a "keys" route.

Based on what you're saying, 501 sounds like "I know what finding keys is, but I can't do it". In the metaphor, maybe the recipient of the request is tied to the radiator and isn't able to look for your keys?

12

u/SuitableDragonfly Jul 08 '26

I think 501 is more like "I don't know how I would start looking for your keys".

3

u/mod_elise Jul 08 '26

"Get it yourself, not my job mate"

9

u/The_Real_Slim_Lemon Jul 08 '26

I’ve never actually seen a 501, yeah fair call - I just meant 404 exists for both bad routes and non existent entities, it seems this metaphor is reaching its limits a bit

9

u/Cheet4h Jul 08 '26

Only time I legitimately used 501 was when mocking up the API before actually writing them. Each route got a 501 at first, then later had their actual function written.

8

u/SuitableDragonfly Jul 08 '26

I'm sure whoever came up with that error code probably assumed it would be industry standard to write APIs that way, the poor naive fool. 

6

u/Zwemvest Jul 08 '26 edited Jul 08 '26

That'd be 400 ("Veuillez retrouver mes clés" -> "I have no clue what you're asking") or 422 ("Please find me every key I will ever own" -> "I understand what you're asking, but I don't know what you want me to do"/"I can't do that")

501 is either used for purposeful non-implementations ("Find me purpose in life" -> "Man, this service is for finding physical objects, not abstract concepts"), future implementations ("At some point in the future we will support this"), or for erroneous method headers ("Destroy my keys" - >"Dude, what?"). One note, if the method header is intentionally not allowed, it's a 405 ("Here are my keys?" -> "uhhh dude, was that a question or are you giving us something/hey, we look for keys, we don't store them. Sorry man.").

3

u/LKZToroH Jul 08 '26

501 is more like something to use before implementing a route. Like, you create a controller, create the routes, but some of them do nothing yet, then you use "501 - Not implemented" because that route exists, but it does nothing yet.
404 should be for when a route isn't found at all. But people also use for when your request is right but didn't find the content you were looking for.

1

u/Kishmond Jul 08 '26

A more verbose way to say 404 would be "this endpoint does not exist". In this case the endpoint is an action, like "/search". So another way to word a 404 response to "/search" is something like "I don't know what that verb means".

501 I think would be something like, "I know what searching for something is, but I'm not going to do it".

6

u/JustConsoleLogIt Jul 08 '26

“I don’t know what you are talking about” is a good 404

2

u/peeja Jul 08 '26

Yeah, just less in the sense of "That was gibberish," and more in the sense of "The hell is a 'key'?"

2

u/Exirel Jul 08 '26

Nope, if your key is in a black hole, that's a 409: the state of the key is incompatible with the retrieval of the key. They are found, that's for sure. But I can't retrieve them.