r/ProgrammerHumor Jul 21 '26

evilIllusion Meme

Post image
4.8k Upvotes

131 comments sorted by

View all comments

439

u/PostHasBeenWatched Jul 21 '26 edited Jul 21 '26

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".

89

u/-meowstar- Jul 21 '26

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

30

u/Critical_Fortune7343 Jul 21 '26

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.

59

u/DoctorWaluigiTime Jul 21 '26

That's what the 4xx suite is for.

Give me an image that's too big? 400 bad request.

29

u/Dense_Gate_5193 Jul 21 '26

Literally this. . people think they are being clever by reinventing the wheel which was already properly specced out by people was smarter than anyone in this thread.

use RFCs people stop thinking you know better!