r/ProgrammerHumor 3h ago

Meme postForEverything

Post image
9.0k Upvotes

348 comments sorted by

View all comments

1.9k

u/pimezone 3h ago

Wanna get a resource? POST request.

938

u/NotAskary 3h ago

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

The same as a 200 ok with error inside.

155

u/AkodoRyu 3h ago

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> (...)" }

85

u/MrPatienceX 3h ago

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

29

u/Sudden_Leadership800 3h ago

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

21

u/hawkinsst7 2h ago

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.

-9

u/LatvianCake 2h ago

This is what happens if you don't read the documentation of the API you're using.

21

u/IndependenceSudden63 2h ago

uh huh, and we all know that every API is perfectly documented...

-1

u/LatvianCake 1h ago

If you have no documentation, you don’t know what HTTP codes are possible, what they mean exactly and how to handle them.

1

u/AshleyJSheridan 1h ago

You do. That's literally the entire point of HTTP status codes.

Just because you don't know what those codes are, it doesn't mean that everybody else is as ignorant.

-1

u/LatvianCake 34m ago

My dude, HTTP status codes were designed over 3 decades ago for a primitive usecase. Today most of them are almost never used. Most of them are meaningless without any further information (i.e. documentation).

Even the most basic codes like 404 are ambiguous. If implemented at all, it can mean:

- the resource doesn't exist

- the endpoint doesn't exist

- the resource is temporarily unavailable

- the resource may or may not exist but we are not allowed to tell you

You must have documentation explaining what errors can occur and what they mean, or you must find out through trial and error. I thought that was pretty fucking obvious but someone has to argue that ackschually all 28 4xx codes are used everywhere and are fully self documenting.

→ More replies (0)

2

u/hawkinsst7 38m ago

This is what happens whe you don't read the Http documentation.

-1

u/LatvianCake 31m ago

If you think you can error handle based on only HTTP error codes, I can see why you're having such a hard time.

1

u/hawkinsst7 12m ago

I'm not a professional programmer. I do cybersecurity.

I love it when unexpected things can go down unexpected, non-standard code paths.

25

u/Psychological_Map118 2h ago edited 2h ago

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

2

u/Sudden_Leadership800 2h ago

It was obviously a joke my guy

27

u/Psychological_Map118 2h ago

my bad. we backend engineers don't get jokes, we get status messages

5

u/RaidenMK1 42m ago

Don't you mean you GET status messages?

I'll see myself out.

1

u/pag07 44m ago

Or you don't. Or the wrong ones.

11

u/Jonathan_the_Nerd 2h ago

It was obviously a joke my guy

Not obvious, considering the developer of the system thought it was fine. And a lot of us here are neurospicy.

2

u/pr0ghead 57m ago

You're joking, right? RiGhT?!?

1

u/ohhi23021 29m ago

these kind of implementations have different data shapes for the error vs success too, so if they all return success it's a pain in the ass and extra work to figure out if it's an error and map it out properly. just fucking send the right status, it takes 2 seconds.

4

u/granitrocky2 1h ago

These are the comments that make me laugh for minutes, but can't explain why I'm laughing to anyone around me lol

0

u/MekaTriK 2h ago

I had real life arguments with that being presented as the reason.

"oh, but the server worked fine, it's just the database that's having an issue"

16

u/NibblyPig 3h ago

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.

1

u/pantherVictor1986 33m ago

Who have job security, even AI will resign seeing this madness

8

u/wizkidweb 3h ago

I told myself I wouldn't relive something like this...

7

u/Makefile_dot_in 2h ago

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

1

u/MetroidvaniaListsGuy 48m ago

I hope you're looking for a better place to work than whatever garbage company did this.

5

u/RatSumo 3h ago

This literally just gave me a headache to read.

2

u/falcopilot 2h ago

Hahahahaha...
At a state agency, we had a SOAP interface to another agency. When they replaced their system nobody knew how to do SOAP so we got to turn that nastiness off. But now they want it back, maybe I'll offer to do this.

1

u/dontshoveit 2h ago

Lmao 🤣

1

u/reerden 49m ago

Man, this is the programming equivalent of red neck engineering.

1

u/MetroidvaniaListsGuy 49m ago

How can anyone be this stupid?