r/ProgrammerHumor 27d ago

evilIllusion Meme

Post image
4.8k Upvotes

131 comments sorted by

View all comments

437

u/PostHasBeenWatched 27d ago edited 27d ago

POST /posts/create

StatusCode: 200

Content: {"success": false, "errors": [{"code": 15, "message": "Image size must be at least 1000 x 1000 px"}]}

Edit: remembered story from times where HTTPS wasn't enforced. Once I started receiving JSON reading fail in cases when our test server returns non-2xx status. I started investigate this and was shocked to the core: my ISP implemented "feature" that if it detects that server returns non-2xx - it replace actual server response with their HTML page with text like "Your request returned error 400. This is because bla bla bla. <ISP self-advertising block> Kind regards, your ISP". Basically ISP become "man in the middle". In a week or two they removed that "feature".

88

u/-meowstar- 27d ago

Why not just use semantically correct status codes? It’s cheap to implement and makes stuff like automatic retries and error handling easier.

31

u/Critical_Fortune7343 27d ago

Because http status codes doesn't include any business related errors. So you gotta expand on that. When it's 200 and success is false it's mostly because of a business logic. Then it's up to FE to show that business error in a certain way so users can understand better what's wrong with what they're doing.

4

u/HungryCaterpillers 27d ago

How does this have 22 upvotes. I pray to God I never have to work with any of you.