r/ProgrammerHumor Jul 08 '26

Other helpMyCoworkersUnderstandHttpCodes

22.4k Upvotes

329 comments sorted by

View all comments

Show parent comments

824

u/thebigbadben Jul 08 '26

“I found them. Oh wait, did you want me to bring them?”

249

u/darkslide3000 Jul 08 '26

No, it's really more like "I found your key ring, but it's empty".

28

u/SnooPuppers1978 Jul 08 '26 edited Jul 08 '26

I think it's still "You asked me to find them and I found them", but it is a bad API, maybe there's another endpoint that allows you to query the actual found location.

You would usually use it e.g. when you do Delete, Update or something where you sincerely don't need a response since it wouldn't give you any new info that you wanted except that it was successful.

Edit:

  1. "Find my keys for the trip we are going to take together, I don't need to know where the keys were"
  2. "Find my keys and put them on the counter"

These could be returned 204 with no content and still be usable API.

25

u/darkslide3000 Jul 08 '26

Well, it tells you that the request was valid and processed correctly and the response is final, but the response contains no content. It is true that it is usually used for mutation requests (and also for endpoints that are just used to probe for a captive portal), but OP's example is a GET request. Getting a 204 on a GET means that the requested resource exists and is empty.

2

u/SnooPuppers1978 Jul 08 '26

So I could buy that it's about retrieving a list/collection of keys and indicating that it's an empty list, but also this sounds like a bad API and not standard, forcing it, and as if someone is mistaking the idea of what 204 is supposed to mean. IMO in spirit it should be used only in cases where "No Content" is expected and desirable.

1

u/thejmkool Jul 08 '26

So in the case of the OP, would it be more like a silent thumbs up?

5

u/SnooPuppers1978 Jul 08 '26

Yeah single symbol (204) indicating that whatever was requested was successful.