this post was submitted on 22 Mar 2025
702 points (98.6% liked)

Programmer Humor

21816 readers
2309 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] nialv7 20 points 1 day ago
HTTP 200
{"status": "success", "payload": "{\"error\": true}"}
[–] [email protected] 23 points 1 day ago

Ah, the 200 Go Fuck Yourself pattern.

I use HTTP error codes in my API, and still occasionally see a GET /resource/{"error":"invalid branchID provided"} from people who don't seem to know what they are.

[–] [email protected] 72 points 1 day ago (7 children)

I know an architect who designs APIs this way. Also includes a status code in the response object because why have one status code when you can have two, potentially contradictory, status codes?

[–] ByteJunk 6 points 1 day ago* (last edited 1 day ago) (1 children)

I may have run in your acquaintance work, stuff along the lines of

200 OK

{ error_code: s23, error_msg: "An error was encountered when performing the operation" }

If you happen to run into him, kindly tackle him in the groin for me.

Thanks!

[–] [email protected] 3 points 1 day ago* (last edited 1 day ago) (2 children)

Well, looking at your example, I think a good case can even be made for it.

“s23” doesn’t look like an HTTP status code, so including it can make total sense. After all, there’s plenty of reasons why you could want custom error codes that don’t really align with HTTP codes, and customised error messages are also a sensible use case for that.

Of course duplicating the actual HTTP status code in your body is just silly. And if you use custom error codes, it often still makes sense to use the closest matching HTTP status code in addition to it (so yeah, I agree the 200 in your example doesn’t make a lot of sense). But neither of those preclude good reasons for custom codes.

[–] Opisek 3 points 23 hours ago

Still, 200 should not be returned. If you have your own codes, just return 500 alongside that custom code.

[–] ByteJunk 1 points 20 hours ago (1 children)

But WHY are you trying to make a case for a bad practice? Don't enable this kind of bullshit, please.

If there's an error, don't say it's 200 OK. Give me something, a 4xx, or at least a 500. Sure, add all you want to the body, but respect the goddamn headers!

This fucks up so many things - starting right with API specs and documentation, s23 (or any other code this crap spits out) are not a part of the pdf file, which is the ONLY available documentation for this 3rd party service. If it serves any internal purpose, I have no clue, but for me it's useless.

Log analytics is a mess, and you can forget about auto-generating a client, of course...

This is just a huge red flag for me, if their public interfaces look like this, I dont want to know whats under the hood, and I'm actively lobbying for us to change to another provider.

[–] [email protected] 1 points 20 hours ago

I’m making a case for custom codes, not for using a 200 status code with it. My reply said the 200 didn’t make sense.

Of course once you use custom codes, the actual HTTP status codes do become less important, because there’s some redundancy there. That’s not an argument to do it wrong, but it is an argument that accurate HTTP status codes are less of a priority. So understandably some people will take shortcuts.

Apparently you find this very frustrating, but in the end it’s just an implementation detail. But it also sounds like you’re more frustrated with the service API as a whole than the fact it uses custom error codes specifically, so I’m just going to leave it at that.

[–] [email protected] 47 points 1 day ago (3 children)

I inherited a project where it was essentially impossible to get anything other than 200 OK. Trying to use a private endpoint without logging in? 200 OK unauthorized. Sent gibberish instead of actual request body format? 200 OK bad request. Database connection down? You get the point...

[–] Jerkface 28 points 1 day ago

It's the HTTP version of "great job."

[–] [email protected] 14 points 1 day ago

Computer version of dude wincing through the pain, tears in eyes, giving you a thumbs up.

[–] fauxerious 10 points 1 day ago (1 children)

Lmao do they work at Oracle???

load more comments (1 replies)
[–] [email protected] 6 points 1 day ago

Ugh this just reminded me that I ran into this exact issue a couple years ago. We were running jobs every hour to ingest data from an API into our data warehouse. Eventually we got reports from users about having gaps in our data. We dug into it for days trying to find a pattern, but couldn't pinpoint anything. We were just missing random pieces of data, but our jobs never reported any failures.

Eventually we were able to determine the issue. HTTP 200 with "error: true" in the response. Fml

load more comments (3 replies)
[–] [email protected] 82 points 1 day ago (4 children)

And no error message...

I guess that's how it's done. Yeah.

[–] [email protected] 20 points 1 day ago (1 children)

Doesn't matter, the client ignores the error anyways.

[–] nogooduser 1 points 20 hours ago

This is very frustrating! I get so many requests from customers asking why we returned response code 400 when we gave a description of the problem in the response body.

[–] [email protected] 5 points 1 day ago

This is always how graphql works :)

load more comments (2 replies)
[–] [email protected] 33 points 1 day ago (1 children)

This became a religious war at my last role.

[–] andrefsp 10 points 1 day ago* (last edited 1 day ago)

I had a similar one at a past work too. A test which was asserting a response status 500.

Like, instead of the test asserting the correct error/status code was being returned, it was instead asserting any error would simply getting masked as a 500.

Basically, asserting the code was buggy....

That made me angry a couple of times but I still miss that place sometimes.

[–] madcaesar 11 points 1 day ago (1 children)

Here I am preferring 200, with success boolean / message string...

Iike HTTP errors codes for real fuck up's, if I see 500 somethings fucked in the app, otherwise a standardised json response body seems way easier

[–] [email protected] 19 points 1 day ago (1 children)

What about both? User supplies bad input? HTTP 400 with response body json describing the error in a standard format?

[–] [email protected] 7 points 1 day ago (1 children)

when you are too lazy to ask your request library to not throw exception on non-200 responses.

load more comments (1 replies)
[–] [email protected] 12 points 1 day ago

Someone GraphQLs

[–] HeyThisIsntTheYMCA 7 points 1 day ago

I always loved how Sierra took its error message and turned it into an intentionally quitting the game message because every time they closed the game, instead of closing properly it crashed.

[–] [email protected] 28 points 1 day ago* (last edited 1 day ago) (5 children)

At a prior job, our ~~API~~ load balancers would swallow all errors and return an HTTP 200 response with no content. It was because we had one or two clients with shitty integrations that couldn't handle anything but 200. Of course, they brought in enough money that we couldn't ever force them to fix it on their end.

[–] herrvogel 27 points 1 day ago

I once worked on a project where the main function would run the entire code in a try-catch block. The catch block did nothing. Just returned 200 OK. Didn't even log the error anywhere. Never seen anything so incredibly frustrating to work on.

load more comments (4 replies)
[–] [email protected] 17 points 1 day ago

Several Favicon APIs do this. Even Google's Favicon endpoint does it, because they return a fallback image. It's pretty annoying.

[–] [email protected] 19 points 1 day ago (5 children)

Welcome to graphQL. The REST abstraction few need, but everyone wants for some reason.

[–] [email protected] 2 points 1 day ago

I looked into it once at my last company, but none of us knew it and we had a tight deadline. For our scale and usecase, it definitely seemed like needless complication for most things compared to any payoff of switching.

load more comments (4 replies)
[–] [email protected] 3 points 1 day ago (5 children)

me with gRPC error codes: nil, parameter error, app error -- OK, you fucked up, we fucked up. Edit: forgot NotFound.

I really should read about the various ones that exist at some point, but I've always got bigger fires to put out.

Edit, since it seems unclear, gRPC != HTTP and does not use the same status codes. I meant that I felt like I was using fewer than I should, though I just checked and basically not.

load more comments (5 replies)
load more comments
view more: next ›