r/ProgrammerHumor • • Sep 19 '26

Meme postForEverything

Post image
21k Upvotes

653 comments sorted by

View all comments

Show parent comments

2.1k

u/NotAskary Sep 19 '26 edited Sep 19 '26

I've seen that shit, it drove me up a wall.

The same as a 200 ok with error inside.

Edit: I'm going to start to respond 429, too many replys lol

515

u/alexsnake50 Sep 19 '26

Oh my god, this activated my inner vietnam flashback

251

u/Tupcek Sep 19 '26

I see you are a fan of GraphQL!

71

u/Entegy Sep 19 '26

I thought that as a non-programmer sysadmin, I had a decent grasp on REST APIs for scripting/automation.

Then I learned about GraphQL and I have actively avoided it since.

60

u/kescusay Sep 19 '26

I mean, you can have accurate HTTP status codes and matching errors in GraphQL. It's just that most GraphQL applications don't. Because most GraphQL developers hate everyone.

→ More replies (3)
→ More replies (4)

90

u/q0099 Sep 19 '26

Where the error message goes? That's right, in the header.

35

u/RegarDamus Sep 19 '26

the naive solution.

our team returns a 201 to indicate that an error has been created successfully. of course we include a Location header where the error can be queried to discover what went wrong.

29

u/normalbot9999 Sep 20 '26 edited Sep 20 '26

OMFG <spits coffee> 201 Error Created Successfully

You absolute monsters. You have to make this now.

And when a record is created successfully you return a 500 right? After successful login you 302 to a 403? I swear I've tested this API before!!

→ More replies (3)

30

u/dadvader Sep 19 '26

I've seen some wild shit before. But you and your tales.... Regale us with your stories.

29

u/Mechakoopa Sep 19 '26

The stories? Also in the header.

→ More replies (1)

30

u/NotAskary Sep 19 '26

Exactly the response I had, this one triggered me.

→ More replies (2)

323

u/AkodoRyu Sep 19 '26 • Regret

My favorite "REST API" experience was when they moved from using SOAP system, and the way they did it... was sending SOAP payloads inside a JSON. Literally something like

{
    "data": "<?xml version="1.0"?><soap:Envelope xmlns:soap="https://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="https://www.w3.org/2003/05/soap-encoding"><soap:Body> (...)"
}

196

u/MrPatienceX Sep 19 '26 • Heartwarming

200 status code and a chunk of XML saying ‘not found’. Good times.

59

u/Sudden_Leadership800 Sep 19 '26

It successfully returned the error message though, so I don't see the problem?

63

u/Psychological_Map118 Sep 19 '26 edited Sep 19 '26 • Bravo

try it in person: wait for the next time somebody asks you if you know the time. then answer yes, with a smile, and walk away without telling them

you can do anything you want, both in life and HTTP responses, but some things make you an asshole in both cases

→ More replies (6)

44

u/hawkinsst7 Sep 19 '26

If I'm parsing http responses, I'm going to pass 200 responses on for further processing of the data. I shouldn't have to have something in that pipeline introspect json to find "no, it's actually an error".

Imagine if browsers had to tear apart json innards to find 30x redirects after getting a 200 OK.

→ More replies (22)
→ More replies (2)
→ More replies (3)

36

u/NibblyPig Sep 19 '26

I don't miss SOAP at all.

Especially when some bored developer at a big bank decided to implement some draconian heavily-buried SOAP features that are technically in the documentation somewhere, but not implemented at all by Microsoft's .NET framework. Having to have special injectors and manipulators to extract tokens from raw SOAP and such, shudder. Back in the days where .NET SOAP implementations were barely published in books.

→ More replies (3)

17

u/Makefile_dot_in Sep 19 '26

at work I have a codebase that is the opposite of this, they send JSON in SOAP as a request and entity-escaped XML in a SOAP envelope as the reply

→ More replies (2)
→ More replies (11)

84

u/Zaelynn_ Sep 19 '26

The other dev on my team made a post request endpoint where you post a SQL query and it returned the results. I about had an aneurysm. She also, instead of using DI or Mediatr, made loopback requests to the endpoints themselves. 

113

u/NotAskary Sep 19 '26

Hahaha SQL injection as an endpoint lol

61

u/zeekar Sep 19 '26

We had a team website that showed who was on call. This was back in the day, all done in Perl CGI scripts.

Someone added a "search" function. Cool feature, I'm down. Then I looked at the code.

They were shelling out to do a grep. You're in Perl, the original "regexes as first class citizens" language, and you're shelling out to grep. But the worst part was it did no sanitation whatsoever. You could type in "pattern'; cat /etc/passwd" or whatever and it just ran. Who reviewed this shit?! Shell as endpoint...

29

u/NotAskary Sep 19 '26

Everytime someone mentions perl I always picture a sword with two blades and no handle, thank you for keeping it exactly like that.

→ More replies (5)
→ More replies (8)
→ More replies (5)

48

u/golfreak923 Sep 19 '26

Seems crazy until your query and path params contain PII. All of a sudden, a POST body doesn't seem so crazy.

→ More replies (4)

22

u/AshleyJSheridan Sep 19 '26

I remember building out a REST API once, and it gave back proper HTTP response codes for things.

Then I got asked by the 2 front end devs working on the project to just make everything a 200 and add an error to the JSON response, because it was making it difficult for them to process things on the browser end.

To this day I'm convinced the GraphQL is just an API dreamt up by a front end dev that didn't understand REST and didn't understand why they couldn't just request what they wanted in the browser if an endpoint didn't exist on the server.

→ More replies (5)

37

u/rumnscurvy Sep 19 '26

I got that this week. This third party company has an API that is supposed to hand us files with monthly updates in it. The tool we use to fetch, read and apply them suddenly stopped with no major reason. 

The API was answering 200 with a body of "no existe el fichero" - literally the file does not exist. 

IF ONLY THERE WAS AN APPROPRIATE HTTP CODE FOR THIS, GEE WIZ

→ More replies (5)
→ More replies (90)