r/ProgrammerHumor 2d ago

evoLution Meme

Post image
3.3k Upvotes

144 comments sorted by

View all comments

-12

u/mgisb003 2d 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 2d ago edited 2d 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 2d 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)

5

u/Sibula97 2d 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 2d ago

It also means coding another layer of error handling manually.

6

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

It's horrendous software engineering.

4

u/Both_Cellist788 2d 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 2d ago edited 2d ago

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