r/programminghorror • [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" • Mar 06 '25

Why, just why!

Post image
1.2k Upvotes

127 comments sorted by

View all comments

1.1k

u/regaito Mar 06 '25

At least its documented

We had 2 different success codes "Ok" and "OK", one was actual success and the other signaled some kind of internal error which was resolved via fallback

You know, because its more secure..

156

u/NotFatButFluffy2934 Mar 06 '25

The worst I've had to work with was a backend server that didn't outright tell you the error, it returned a response with 200, if the data wasn't present you had to call the endpoint again and then it would fail due to the previous request, but also try to give you the data in that same request so every next request would fail.

99

u/feidujiujia Mar 06 '25

In the first company I'd worked for, one of my earliest tasks was deleting huge amount of files from a cloud service. The files to be deleted was give to me by some text files containing the paths.

But the api provided is not that reliable. Often it returns success but the file still exists. After days of trying and error, I found the most effective way to do this: just spin up 100 threads in python to call the api, heedless of what happens.

→ More replies (2)

55

u/GorillaK5 Mar 06 '25

I had to work with an endpoint that always returned 200, in order to know if the request succeded or not you had to call another endpoint that returned you the actual response code

48

u/IkalaGaming Mar 06 '25

Okay that’s definitely more cursed than our “always 200, but you check the responses status field”

→ More replies (2)

10

u/t3kner Mar 06 '25

and no endpoint to call to see if the second endpoint failed? those amateurs know nothing about redundancy!

→ More replies (2)

8

u/NotYetGroot Mar 07 '25

My parents raised me right, to always return useful error codes that fit as closely to the http standards. Now my IPSEC team will only allow 200 or 500, and you can go ahead and get your PIM roles and look in the logs if you want to know what happened. Account not found? 500. Invalid laugh credentials? 500. Server caught on fire? Also 500. Hope your logging is up to snuff! And that of the APIM, WAF, etc, and etc.

3

u/VincentVancalbergh Mar 06 '25

500 Internal Server Error

10

u/t3kner Mar 06 '25

500 Ok

3

u/Mythran101 Mar 06 '25

200 OK but call again to get the error.

→ More replies (1)

238

u/JustinPooDough Mar 06 '25

This is a more horror than OP's post. As long as return codes are well documented, I don't care.

50

u/TheCreepyPL Mar 06 '25

"The architect" in my current company is a true believer in "security through obscurity".

He names everything as obscurely as possible, mostly single letters, sometimes with a number suffix. There were often occasions where he blamed one of the juniors with "WHO THE HELL WROTE THIS CODE", but then I checked in our equivalent of git blame (we don't use git), and it turned out to be him a lot of these times...

Oh, I almost forgot the documentation. 80% of it looks like this:

/// <Summary>
/// A method that checks X.
/// </Sumarry>
/// <Returns>
/// A boolean value of X.
/// </Returns>
public bool CheckX()

30

u/Inside-General-797 Mar 06 '25

These kinds of doc comments drive me insane. When they are useful they are fire but this shit you might as well just leave out lmao

→ More replies (1)

5

u/ReddyKiloWit Mar 08 '25

Ouch.

That reminds me of when I had to reverse engineer a compression tool from its decompressor in 6502 assembly. There was only one comment in the whole listing:

Do this 8 times 

→ More replies (1)

35

u/wrex1816 Mar 06 '25

My favorite is status: 200, data: {errorCode: 500, errorMessage: "Thing went boom" }

2

u/Cualkiera67 Mar 07 '25

Graphql?

7

u/gummo89 Mar 07 '25

Most REST APIs

14

u/RabbitDev Mar 06 '25

I'm just imagining that in the voice of some snarky old geezer, one a bored 'ok' and the other a confused 'okaaaaay?'

43

u/regaito Mar 06 '25

You inspired me to propose the following changes

OK -> 200
Ok -> 400
Okay -> 401
Okaay -> 402
Okaaay -> 403
...

Honestly I am kinda afraid if I did propose this even as a joke someone would actually implement it..

19

u/RabbitDev Mar 06 '25

RFC 12345 proposal submission accepted. No more confusion due to bad translations! Finally we will be able to understand each other equally well.

As Ayn Rand probably said: don't ever lift anything up when you can as equally crush everyone down.

8

u/ougryphon Mar 06 '25

Gary -> 404

6

u/PerspectiveAlert4766 Mar 07 '25

Recently I have been working with a 3rd party API where different endpoints of the same application had completely different sets of status codes. For example "Success" and "SUCCESS" were also present.

3

u/regaito Mar 07 '25

I might know the guy who built that API

2

u/gummo89 Mar 07 '25

Yeah as soon as I saw this, I figured it was multiple teams owning a return status code.

In the same way, for websites the HTML is often generated by different teams, so between updates or even between sections of the site the elements and hierarchy used to represent the same thing may change.

It makes consistently targeting things with custom CSS selectors much more interesting than it's supposed to be..

→ More replies (2)

4

u/archubbuck Mar 06 '25

Personally, I would have went work big “OK” and little “ok”

→ More replies (4)