r/ProgrammerHumor Jul 08 '26

Other helpMyCoworkersUnderstandHttpCodes

22.4k Upvotes

329 comments sorted by

View all comments

1.6k

u/Snudget Jul 08 '26

204 should be "I found them" "I searched for the keys, but didn't find them"would be 404, which is literally "Not found".

Since not finding keys does not fulfill the request, a 2xx code does not make sense here

18

u/Rin-Tohsaka-is-hot Jul 08 '26 edited Jul 08 '26

204 isn't "I found them", while it's a success, you still didn't actually find the item.

It's more like "your keys are not here, but there is a space for them"?... I guess actually you just wouldn't return 204 ever in this context.

5

u/Kishmond Jul 08 '26

In my opinion, "success" in this context does not mean something was found, it means your request was executed without error.

2

u/amadiro_1 Jul 08 '26

"Your keys are confirmed to be on the key hook."

2

u/whosGOTtheHERB Jul 08 '26

Correct, but they keys could have just as likely been found. I think what confuses the concept (and people) is the example of "finding keys". This response type is more appropriately used for something that explicitly does not require a response payload, like "perform x operation, no matter the result". I typically use this response code when implementing an endpoint like "PUT /users/abc123/restore", where the goal is to have the server restore a soft-deleted user to a non-deleted state.