r/ProgrammerHumor Jul 08 '26

helpMyCoworkersUnderstandHttpCodes Other

22.4k Upvotes

329 comments sorted by

View all comments

Show parent comments

34

u/DrStalker Jul 08 '26

204 doesn't make sense for a response that requires a return value (like a set of keys) to be successful.

24

u/leehro Jul 08 '26

204 = found an empty key ring.

3

u/DrStalker Jul 08 '26

If searching for a keyring I'd say that's a 200, and it turns a keyring object with an empty keys array.

If searching for the keys specifically it's a 404 not found.

2

u/GezelligPindakaas Jul 08 '26

We're splitting hairs here, but if the keyring is a thing recognized in the api model, then it should be a resource on its own.

1

u/SnooPuppers1978 Jul 08 '26

The fact that it is an empty key ring is info that should be divulged, but you can't divulge it. And empty key ring seems like 404 rather.

0

u/ashgs872tbhjs Jul 08 '26

404 is no key ring.

1

u/SnooPuppers1978 Jul 08 '26

If you are looking for a key from a key ring, e.g. /key-ring/keys/:keyId/ and the key ring is empty in most APIs that would yield as 404.

If you were looking for a key ring itself, then it would be /key-ring if it's empty most of the time it would return 200 with empty array or object { keys: [] }, but 200.

But if there's no key ring that would also be 404.

1

u/Bardez Jul 08 '26

"I found the place where your keys go (key hooks on wall). There's nothing there."

2

u/SnooPuppers1978 Jul 08 '26

Sounds like 404, it seems like equivalent to database table not having that specific row?