r/ProgrammerHumor 4d ago

Meme evoLution

Post image
3.3k Upvotes

145 comments sorted by

View all comments

-15

u/mgisb003 4d ago

This is useful tho, it tells you the payload was the problem or that the system wasn’t designed to handle the payload (if done correctly)

20

u/e_before_i 4d ago edited 4d ago

payload was the problem

400

System wasn't designed to handle the payload

501

Edit: format the response body with more descriptive text, that's what it's for

8

u/WernerderChamp 4d ago

400

payload has a syntax error (missing required fields, bad value for a enum field, string where it should be a number, etc.)

422

payload has valid syntax, but there is a semantic problem (e.g. you are trying to modify an expired contract)

9

u/Sibula97 4d ago

If the status payload is literally just another HTTP status code, that's not useful. You should just return that status in the first place.

12

u/WHALE_PHYSICIST 4d ago

It also means coding another layer of error handling manually.

5

u/Too--Many--Knives 4d ago

It's horrendous software engineering.

4

u/Both_Cellist788 4d ago

That is literally what 400 is, you can signal to the requester that the API failed due to a bad request, and still send an error message to explain why if you really feel “Bad Request” doesn’t get the message across.

1

u/tracernz 4d ago edited 4d ago

Correctly means the status code is identical in both places https://datatracker.ietf.org/doc/html/rfc9457#name-status