this post was submitted on 11 Jun 2024
450 points (99.1% liked)

Programmer Humor

22839 readers
565 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
 
all 28 comments
sorted by: hot top controversial new old
[–] palordrolap@kbin.run 129 points 10 months ago (5 children)

Better than a 200 JSON reply containing the 4xx. "Aay it worked!" "oh."

[–] boonhet@lemm.ee 55 points 10 months ago (1 children)

Worked at a company where the previous devs had implemented their own frameworks for front and backend. Obviously 200 was the only possible code.

[–] Dultas@lemmy.world 10 points 10 months ago

Not even 418?! Uncultured swine.

[–] jballs@sh.itjust.works 34 points 10 months ago (3 children)

This legitimately happened to me a few months ago. A vendor API was returning HTTP 200 with the error details embedded in the JSON response. It was a pain in the ass to troubleshoot.

[–] morbidcactus@lemmy.ca 2 points 10 months ago* (last edited 10 months ago)

Yeah, had that happen a few years ago, thankfully there was a consistent status attributes in the response that I could use but still, annoying

[–] Ironfacebuster@lemmy.world 2 points 10 months ago (1 children)

I guess I might be evil but when I made APIs for my projects I do this, since I blindly accept the response then look at the JSON to see if it was accepted or not

Something like

if (body_has(JSON)) do_stuff_with(JSON) // including error handling if the response has an error else error_no_json()

I do this since I feel like JSON errors should be separate from HTTP errors

[–] jballs@sh.itjust.works 4 points 10 months ago (1 children)

The problem I ran into was the response returned a JSON body, but then had an "error" attribute that was returned in it that had the error details. So we were parsing the JSON and loading elements into our database. We were hitting the API passing in a datetime of when the last success job was run, so basically saying "give me everything that's changed since I last called you."

So yeah, eventually we noticed we were missing small chunks of data. It turned out that every time the API errored out, we'd get a valid JSON response that contained the error message, but it didn't have the attributes we were looking for. So didn't load anything, but updated our timestamp to say when our last successful call was.

Huge pain in the ass to troubleshoot, because the missing data was scattered with no distinguiable pattern.

[–] calcopiritus@lemmy.world 2 points 10 months ago (1 children)

Why not respond with the appropriate HTTP Code, and then also put the same code in the json?

[–] jballs@sh.itjust.works 2 points 10 months ago

That would have been fine for me too. I don't own the API, so I can only speak from a consumer perspective in saying: I don't want a HTTP 200 if my request didn't succeed.

[–] magic_lobster_party@kbin.run 25 points 10 months ago

“Task failed successfully”

[–] capnminus@lemmy.world 13 points 10 months ago

what the fuck

[–] fibojoly@sh.itjust.works 8 points 10 months ago (2 children)

I've had this so often... very frustrating.

I like to think the 400 within a 200 is for "look, I managed to reply to you. But there is bad news"

[–] vithigar@lemmy.ca 7 points 10 months ago

You can give a 400 response a body though. It doesn't stop you from replying.

[–] lseif@sopuli.xyz 6 points 10 months ago (1 children)

regardless, its a big red flag for a poorly designed api

[–] fibojoly@sh.itjust.works 3 points 10 months ago

Oh I agree! It was so annoying.

[–] lazyneet@programming.dev 51 points 10 months ago

The sad reality is that when you look at the files being requested, it's usually scrapers looking for exploits.

[–] azezeB@discuss.tchncs.de 44 points 10 months ago

You can't have bugs if it's always the caller fault

[–] cupcakezealot@lemmy.blahaj.zone 42 points 10 months ago

can't have a website problem if every page is 404 taps forehead

[–] bruhbeans@lemmy.ml 24 points 10 months ago

Deleting all the S3 buckets on my way to the exit interview

[–] 9point6@lemmy.world 20 points 10 months ago

releases a change where all routes accidentally go to the error page controller

🤷‍♂️ They're 4xx errors, won't be us

[–] fubarx@lemmy.ml 18 points 10 months ago (1 children)

All 418 error codes. We good.

[–] tgxn@lemmy.tgxn.net 5 points 10 months ago

It's all teapots all the way down.

[–] Ironfacebuster@lemmy.world 12 points 10 months ago

if (request.ip != myip) return ErrorCodes.NotFound

And an ipv6 version for all you up 6 fans

if (request.ipv6 != myipv6) return ErrorCodes.NotFound

[–] Thorry84@feddit.nl 9 points 10 months ago

3** status codes: 4000%

Oops

[–] thr0w4w4y2@sh.itjust.works 7 points 10 months ago

a pretty grafana dashboard? peak web traffic looks a lot nicer than i thought!

[–] key@lemmy.keychat.org 4 points 10 months ago

Alternatively all 504 Gateway Timeout

[–] privatizetwiddle 2 points 10 months ago

"Not my problem" code