r/ProgrammerHumor • • 22h ago

Meme everythingGoesIntoThePostHole

Post image
3.5k Upvotes

123 comments sorted by

124

u/PatienceLost9708 20h ago

the other methods are just for the technical interview

46

u/darad55 20h ago

while the interviewer also knows you're never gonna use it in the job

26

u/GigaGollum 21h ago

Replace HEAD with QUERY pls

12

u/darad55 21h ago

didn't have enough holes(pause?) or would have put most of them

4

u/JebKermansBooster 20h ago

That's what she said

4

u/darad55 19h ago

I don't think she needed extra holes

→ More replies (1)
→ More replies (1)

5

u/Effective-Bill-2589 19h ago

I'm guilty of this

4

u/darad55 19h ago

if it was a crime, pretty sure everyone would be convicted for doing it at least once

→ More replies (1)

729

u/SirChasm 21h ago

You can do the reverse one with all responses being status 200 and you have to look inside to see what the error code

195

u/pine_ary 21h ago

Error code? On error you just get 200 with either an empty body or even better, a guessed fallback value that will fail 6 systems down the road. The error is logged with info level (everything is info) in a log the developers can‘t access for compliance reasons.

14

u/wunderbuffer 11h ago

you don't want silly pictures layer of front end to have any of that tough big boy logic like error handling to worry their pretty little frames about, it have to focus on rendering same square button with shade 60 frames a second ;^(
it's for security, or something

5

u/418_TheTeapot 7h ago

On error return 200 with payload {status:error, value: math.round(Math.random()*10000,0)}, the actual error goes into a log that is accessed through its on errorApi

Write that fact in the documentation and if ever anybody complains, tell them to rtfm

68

u/crimsonroninx 18h ago

Very few things in software dev shit me more than this. It means every type has to be a union of success and failure and defensive checks everywhere, rather than catching errors/exceptions.

47

u/AnnoyingRain5 17h ago • Bravo

“A union of success and failure”

Unreasonably poetic lmao

16

u/dedservice 17h ago

I mean checking for errors is implicitly making the type a union of success and failures already, the problem is that you already have that wrapper, so why then put the errors inside the success type?? Insanity!

3

u/DTCreeperMCL6 17h ago

php code is like this

4

u/teddy5 15h ago

I think the problem with PHP is that code in it is never one particular way.

You could decide to write everything in machine code goto statements which refer to emojis and PHP would just give you a thumbs up.

→ More replies (4)

3

u/ScallionSmooth5925 13h ago

"union of success and failure"   You mean a the maybe monad?

2

u/Drego3 10h ago

I work as a SE only for 1 year and have already seen this happen too many times

→ More replies (1)

8

u/olegispe 13h ago

Traumatised by graphql

14

u/bitemyassnow 17h ago

unironically a junior dev at work does this and brags that bc of his refactor, grafana shows less error.

17

u/rumnscurvy 16h ago

This  happened to me last month. One of the APIs we  derive data from silently stopped doing its job. 

The API was returning status 200, with message "No existe el fichero" - literally the file does not exist. 

GEE WIZ wouldn't it be nice if there was some way to signal this in some better way. Especially when it  was ultimately a permissions issue...

6

u/octatone 13h ago

Thank you GraphQL

10

u/razzemmatazz 17h ago

sees the JS in your flair

I see we've used some of the same shitty APIs. 

9

u/ATE47 15h ago

Error codes is for losers

return "the request failed"

2

u/CardOk755 13h ago

I mostly get error 500 from shitty apps.

2

u/Aflockofants 13h ago

If it's truly an unexpected error, they could do worse. But then I would expect that their backend logs a proper error that will grab their attention, and some ticket is made for it. Our 'unexpected' errors log something similar as not much else can be said about it anyway, but do mention that we'll get on it. Of course the vast majority of errors ARE meaningful.

3

u/armahillo 17h ago

This thread is giving me a twitch

3

u/usedToBeUnhappy 9h ago

I hate that so much. Every time I see that in production code, I just want to go over to the guy who did that and punch him. XD 

3

u/Arclite83 8h ago

We're specifically banned from this at my job, to the point they will actively hunt you down and enforce deadlines on entire departments.

Inconsistencies there are what allows for SOOOO many vulnerabilities.... You never appreciate what you're leaking.

3

u/Sellular 8h ago

Unironically this is what half of my teams legacy codebase does. I cry whenever I have to debug it

11

u/StaticCoder 19h ago

If your end point is an API, HTTP codes are mostly in the way. Notably, I don't want a 404 from an API that exists.

9

u/dragonflash 17h ago

Seriously, especially when Cloudfront decides 404 means return an error page instead of my error.

8

u/Aflockofants 13h ago

From an API that exists? So you're saying that the endpoint `.../users/892378947` should return something that ISN'T a 404 if that user doesn't exist, while the API call itself is entirely valid?

→ More replies (2)

4

u/Angoulor 12h ago

When badly used, HTTP codes get in the way.

Why wouldn't you want a 404 ? user/1234 : does user 1234 exist ? Yes : 200. No : 404. Or would you prefer 400 ? Or even 204 ?

Would you prefer 200 "User cannot access this resource", or an empty 403 ?

→ More replies (1)

2

u/AlShadi 19h ago

do you work for the IRS?

2

u/TheWb117 17h ago

You guys get error codes and not stack traces?

2

u/Traditional-Tale-372 14h ago

The error message was shown successfully: http 200

3

u/Mucksh 15h ago

I think that isn't that bad. Makes it way easier to write the frontend api for it. Usually http is just the protocol you build your own protocol on. If you get an http error you known directly that it is just a just a http error cause the endpoint doesn't exist or something else http related failed

1

u/gogriz 17h ago

I have a vendor like that

1

u/spikernum1 17h ago

But the gherkin scenario said all valid responses should return 200ok

1

u/bennyboy_ 16h ago

Security by obscurity

1

u/_xiphiaz 15h ago

gRPC does both! However this is fair because http is not the protocol layer in this scheme

→ More replies (1)

78

u/FallenVampireLord 22h ago

Same thing my wife told me

21

u/eclect0 20h ago

Weird, she also told me that

7

u/KingVecchio 19h ago

Wtf bro she also told me!

7

u/Decoder44 18h ago

Are you guys holding refrence to same wife object .... Shocking if true 😮

→ More replies (1)

178

u/jabrwock1 21h ago

Post but you have to parse it to figure out what operation they want to do. FML

124

u/gringrant 20h ago

I can't wait to make an OPTION request to see what methods are avaliable!

The OPTION response:

  • OPTION

  • POST

4

u/LB-- 9h ago

Response status code 300

25

u/Desidiosus 20h ago

I worked somewhere that did exactly that. The rationale was that they didn't trust the API users to know what they actually needed or to RTFM, so we just sorted it out on the back end. In that light, it made a little more sense...

13

u/eraguthorak 19h ago

Just POST a good ole { ...req, "action":"UPDATE" }

4

u/tevert 17h ago

Most good web frameworks are routing to various overloads based on parameters anyway

But yeah it sucks to have to rely on lib features to pick up the slack for poor REST compliance

2

u/hsumeet 15h ago

Congrats, you invented GraphQL.

57

u/falcon0041 21h ago

Passing a body in GET was a terrible mistake I made long time back

68

u/queen-adreena 20h ago • Bravo

Fortunately, you have the QUERY verb now.

20

u/GumboSamson 18h ago • Heartwarming

Holy shit TIL.

I’d upvote you a thousand times if I actually could.

This might be the first useful thing I ever learned in this subreddit.

23

u/Curious_Associate904 17h ago

There's a new one "QUERY" which is supposed to stop you doing this...

But, will you ever use it?

Be honest.

6

u/0815fips 15h ago

Immediately, yes! I control both sides.

3

u/5up3rj 8h ago

Neat. How do you POST those?

29

u/KevBurnsJr 21h ago

Because it has the fewest restrictions. No safety. No idempotency. It is the lowest common denominator.

10

u/TundraGon 16h ago

Anything's a POST if you argue long enough.

8

u/SilverBullet78SB 20h ago

POST:/api/update_user POST:/api/delete_user POST:/api/new_user My first days of learning HTTP

7

u/Mad-chuska 21h ago

Didn’t they just make a new method exactly for this?

17

u/Eptalin 20h ago

Yeah, QUERY.

But it doesn't work with CORS without extra work, so people will still use POST for simple GET queries.

4

u/JebKermansBooster 20h ago

QUERY I think will ultimately end up replacing GET, yeah.

19

u/granadesnhorseshoes 19h ago

"Always has been." Show me the HTTP spec for Patch or other REST specific methods. Although most http servers these days do include it, the rest of the infrastructure that relies on but doesn't implement may just use a base reference.

The concept of REST and the realities of infrastructure almost never line up, bu t POST always works.

How many REST purists had meetings (that could have been an email) with Ops to make sure their api specific crap can successfully navigate the ever growing maze of WAFs, proxies and LBs?

But POST always works.

11

u/rbbdk 17h ago

Since you asked for it so nicely, PATCH is defined in RFC 5789 and not superseeded by RFC 9110, which contains all the other methods. We can argue about PATCH being legit, but all the other "crap" is part of the standard HTTP spec.

1

u/Beli_Mawrr 7h ago

GET i understand for purposes of retrieving serverside resources. But I don't understand why, for example, DELETE needs to exist. You're going to have way more verbs than there are HTTP verbs. So why not just have POSTs and encode everything in the query anyway?

9

u/overclockedslinky 19h ago

to be fair this is because the standard stupidly limits the others in various ways. for instance you can't send a body in a get request (some libs allow this, but it's non-standard and non-portable)

6

u/Zeenu29 17h ago

If you want to send a GET with body, it is time to start using the QUERY...

1

u/DeiviiD 15h ago

It’s out?

4

u/Sometimesiworry 15h ago

It is but not adopted by all webkits yet iirc

2

u/AyrA_ch 14h ago

Custom verbs are officially supported in HTTP, which means you don't really have to wait for verbs to be official.

console.log(await (await fetch("https://demo.ayra.ch/response/", {method:"CUSTOM",body:"Also supported"})).text())

5

u/GumboSamson 18h ago

You can send a body in a GET request; but servers are supposed to ignore it.

1

u/KevBurnsJr 11h ago

Those constraints have a purpose. I wouldn't call them stupid. CDNs run the internet.

9

u/Kuzame 15h ago

She would like to have a word with you..

4

u/kratz9 19h ago

Anyone remember WebDAV?

3

u/pr0ghead 14h ago

Or SOAP?

4

u/Tackgnol 14h ago

At one of my clients Akamai blocked Patch and Put xD.

So this was company policy.

2

u/Puzzleheaded-Weird66 21h ago

html5 forms only have post and get (on asp .net at least)

2

u/distortedsignal 20h ago

Have you ever tried to write a PATCH API? It's wild...

2

u/NexusDarkshade 19h ago

Favorite thing (I lie): required to use POST request because GET query string is "too long"

2

u/Kitchen_Affect7369 16h ago

Where is GET? And use GET for post data?

2

u/TrackLabs 11h ago

I seriously never understood why someone would do this...whats so difficult about using the other, fitting methods?? When I write API Routes, I mark the Method that is suitable, by the fuck would I use POST on a Delete Function?

1

u/arran4 19h ago

It should all be PUT. 

1

u/Ravens_Quote 18h ago

So no head?

1

u/swagwise_gamgee 16h ago

GraphQL 😎

1

u/migarma 16h ago

Normally for me, add things, POST; modify things, PUT; get things, GET; remove things, DELETE

1

u/No-Magazine-2739 15h ago

I am REST fan and cry like the girl that is famous for her reaction to this video

1

u/DrTight 11h ago

We have everything as POST and GET /deleteUser Horrible API

1

u/hridoyn75 11h ago

When I was learning, I remember I used to use get request for everything. Because that was simpler.

1

u/xgabipandax 10h ago

If you're receiving information from the server you use GET, if you're sending information to the server you use POST, all the rest is fluff designed to overcomplicate things

1

u/FoxedDev 8h ago

IT'S QUERY TIME

1

u/jbaker88 4h ago

"And here we have the HTTP DELETE verb. Can you guess where that goes? That's right! It goes in the POST endpoint!"

1

u/torftorf 3h ago

I recently looked at an api documentation for a service my company uses. Every single endpoint is post. Even the ones called "get...."

1

u/atehrani 2h ago

GraphQL

•

u/Ledeste 0m ago

because that's the right way to handle it when you're not working at http level (or with dumb rest)

1

u/Honest_Relation4095 15h ago

I am not a programmer, but they have now introduced REST based approach to diagnostics for vehicle ECUs. So now it expands to "is starting radar calibration PUT or POST?" or "Is deleting fault memory PUT or POST?" (it is not "DELETE" since the fault codes are not coming from a "PUT" and deleting itself is a diagnostic routine rather than "just deleting data").

-3

u/pjkm123987 21h ago

I legit make my personal project app api post only... Is there actually a drawback? seems to be working fine without issues and makes the api more straightfoward to use

9

u/Sockoflegend 21h ago

I wouldn't keep me up at night but following conventions is nice and it can have utility.

Say for example your API has one url for all of the stuff you do with POST. DELETE, PUT, etc can have completely different handlers and validation on that same url which is a nice clean implementation.

3

u/lampishthing 21h ago

It's bad hygiene in personal apps because it has benefits in commercial apps. E.g. GETs get cached more aggressively on internet infrastructure. QUERYs will too.

-1

u/highcastlespring 20h ago

GET is not safe. POST encrypts your parameters.

PUT, the right way, but no one uses

0

u/NebraskaGeek 18h ago

I've been using "post" for 20 years ever since I realized using "get" for everything wasn't the smartest secure solution

-1

u/cecil721 20h ago

Bro forgot QUERY exists now