r/ProgrammerHumor • • 19d ago

Meme everythingGoesIntoThePostHole

Post image
4.3k Upvotes

153 comments sorted by

159

u/PatienceLost9708 19d ago

the other methods are just for the technical interview

50

u/darad55 19d ago

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

27

u/GigaGollum 19d ago

Replace HEAD with QUERY pls

12

u/darad55 19d ago

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

4

u/JebKermansBooster 19d ago

That's what she said

4

u/darad55 18d ago

I don't think she needed extra holes

1

u/JebKermansBooster 18d ago

Never know. Maybe she's a nympho?

0

u/gilium 18d ago

None of us in this sub will be receiving HEAD

5

u/Effective-Bill-2589 18d ago

I'm guilty of this

4

u/darad55 18d ago

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

1

u/RepresentativeCat553 18d ago

It POST and DELETE and the others we don’t us

-1

u/RAMChYLD 18d ago

Same. It’s either POST or GET (for readahead queries. Because my boss insists that the user be able to type and select from a drop down, so that’s the best compromise I can come up with).

869

u/SirChasm 19d 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

238

u/pine_ary 19d 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.

20

u/wunderbuffer 18d 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

10

u/418_TheTeapot 18d 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

75

u/crimsonroninx 18d 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.

50

u/AnnoyingRain5 18d ago • Bravo

“A union of success and failure”

Unreasonably poetic lmao

17

u/dedservice 18d 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 18d ago

php code is like this

7

u/teddy5 18d 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.

3

u/DTCreeperMCL6 18d ago

Ooo I didn't know you could use goto in php thanks for the knowledge.

9

u/teddy5 18d ago

Wait. No... I've made a horrible mistake.

I actually thought that example was so far out of field that it wouldn't be possible even in PHP.

2

u/DTCreeperMCL6 18d ago

https://www.php.net/manual/en/control-structures.goto.php

It does have goto idk about emoji names though, ill try it

1

u/DTCreeperMCL6 5d ago

I finally tried it, I needed a goto so I was like why not. It works LMAO

1

u/DTCreeperMCL6 18d ago

Oh you didnt know if you could you were just saying it as a hyperbole? Ill check then. Im a fan of goto statements so I would use them if there were ones

1

u/SirChasm 17d ago

1

u/DTCreeperMCL6 17d ago

I dont know I just enjoy it lol

3

u/ScallionSmooth5925 18d ago

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

2

u/Drego3 18d ago

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

0

u/Beli_Mawrr 18d ago

I'd really rather have the error checking at a level above the browser. I don't want to deal with 400 or 500 error codes clogging up the debugging console. In typescript/nextjs this is a fairly easy thing as the return types can be set to include error messages or success messages. Problem solved.

9

u/olegispe 18d ago

Traumatised by graphql

20

u/rumnscurvy 18d 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...

14

u/bitemyassnow 18d ago

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

7

u/octatone 18d ago

Thank you GraphQL

13

u/razzemmatazz 18d ago

sees the JS in your flair

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

9

u/ATE47 18d ago

Error codes is for losers

return "the request failed"

2

u/CardOk755 18d ago

I mostly get error 500 from shitty apps.

4

u/usedToBeUnhappy 18d 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/armahillo 18d ago

This thread is giving me a twitch

3

u/Arclite83 18d 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 18d ago

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

13

u/StaticCoder 18d 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.

10

u/dragonflash 18d ago

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

5

u/Angoulor 18d 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 ?

-1

u/StaticCoder 18d ago

I don't want a 404 from an API that exists because that allows backwards compatibility, since 404 is what I get for an API that doesn't exist. If I get a 404 I can fall back to an older API for instance.

I'm perfectly happy with an API returning 200 and some JSON with "user doesn't exist".

2

u/blckshdw 17d ago

But it doesnt exist. That’s the point. It’s a Uniform RESOURCE Locator. The RESOURCE (user) does not exist. The URL is invalid. Just because there are other resources with a similar-but-different path doesn’t matter.

-1

u/StaticCoder 17d ago

Well it matters to me because it allows me to tell between a server that has the API and one that doesn't.

2

u/blckshdw 17d ago

You’re confused and not understanding the words. It “doesn’t have an API” when the resource does t exist. 404 does NOT mean the route is incorrect. It means the RESOURCE was not found. It is a client side “you fucked up, try again the right way” error.

It sounds like you’re using 404 to determine if you’ve even got the right server, which is nutty. How do you not know what server/api path you’re supposed to be calling? How are you even sending not existing data to the API.

In the user example 1234 doesn’t exist. Where’d you even get that from that you think that’s valid?

0

u/[deleted] 18d ago

[deleted] — view deleted comment

0

u/StaticCoder 18d ago

Yes! If an API returns structured data it can tell me anything, including "user doesn't exist". I want to be able to distinguish that from hitting a server that doesn't have the API. Otherwise I have to attempt to parse the response as JSON, and if it fails to parse or doesn't match the expected format, then assume the API isn't present and fall back to something else. I've had to do that and it's not pleasant.

0

u/[deleted] 18d ago

[deleted] — view deleted comment

1

u/StaticCoder 17d ago

I'll have to trust you about a good chunk of REST logic being related to HTTP codes (I only wrote simple client code), but again my use case is version compatibility, so an agreed upon API is not possible without a version check. Which I suppose is possible to do, but that adds complexity plus latency on the "happy path".

1

u/blckshdw 17d ago

Latency? wtf are you talking about. There’s many common ways to request a specific version.. url path (/api/v1/user), send it in the header, different host and, etc etc. if that’s adding significant latency you’re doing something very wrong.

2

u/AlShadi 18d ago

do you work for the IRS?

2

u/TheWb117 18d ago

You guys get error codes and not stack traces?

2

u/Traditional-Tale-372 18d ago

The error message was shown successfully: http 200

2

u/Short_Change 17d ago

I never realised why people did this until I was 5 year into my job.

There are errors that are known and errors that are not known. Distinguishing them is actually really important in most scenarios. Is there a better way to do this than passing back 200? yes but I can see why people do this.

2

u/sudoku7 17d ago

Largely that's the difference between 4xx and 5xx, no?

1

u/bloody-albatross 17d ago

What do you mean errors that are known or not know? Do you have examples? In any case it's either a client or server error, so at least use 400 or 500.

1

u/Short_Change 17d ago

{ "status_code": 400, "error_type": "CLIENT_INCOMPETENCE_EXCEPTION", "error_details:" "I sure hope this error doesn't affect my appdynamic metrics"}

1

u/EvilCodeQueen 14d ago

Yes, but you don’t want to give out actual errors to connections for security reasons. Hackers love getting extra information.

3

u/Mucksh 18d 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 18d ago

I have a vendor like that

1

u/_xiphiaz 18d ago

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

1

u/Head-Bureaucrat 17d ago

I feel like this can swing too far in the other direction, and I've worked with APIs that returned a 404 even though the request was valid, the resource was correct, but a specific data point just couldn't be found.

Imagine troubleshooting a failed call and asking yourself "was this valid and the account wasn't found? Or did the path change? Or did the subdomain change?" with no extra information!

406s? Not in this world!

1

u/samanime 17d ago

-sharpens pitchfork-

No.

1

u/Outside-House-7655 17d ago

Ooh my company does this. We then noticed that status codes would be useful and introduced status which has to be there in each json packet. Then the app handled one specific status code in a way that was wanted for basically all responses so we always use that status code and added statusmessage, which is a string but works basically like a statuscode. It’s disgusting in a way words cannot describe.

0

u/CardOk755 18d ago

My favorite is apis that return error 500 if you send a malformed request because the developer was too stupid to trap the exception.

0

u/bennyboy_ 18d ago

Security by obscurity

83

u/FallenVampireLord 19d ago

Same thing my wife told me

23

u/eclect0 19d ago

Weird, she also told me that

7

u/KingVecchio 19d ago

Wtf bro she also told me!

9

u/Decoder44 18d ago

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

70

u/falcon0041 19d ago

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

86

u/queen-adreena 19d ago • Bravo

Fortunately, you have the QUERY verb now.

28

u/GumboSamson 18d 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.

195

u/jabrwock1 19d ago

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

134

u/gringrant 19d ago

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

The OPTION response:

  • OPTION
  • POST

6

u/LB-- 18d ago

Response status code 300

26

u/Desidiosus 19d 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...

12

u/eraguthorak 19d ago

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

4

u/tevert 18d 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 18d ago

Congrats, you invented GraphQL.

33

u/Curious_Associate904 18d ago

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

But, will you ever use it?

Be honest.

11

u/0815fips 18d ago

Immediately, yes! I control both sides.

7

u/5up3rj 18d ago

Neat. How do you POST those?

1

u/blckshdw 17d ago

…. You QUERY them … 👀

1

u/blckshdw 17d ago

Yes.

Will I have to explain it 15 times to other devs? Also yes.
Will I have to explain why I can’t just do POST? Also yes.

31

u/KevBurnsJr 19d ago

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

11

u/TundraGon 18d ago

Anything's a POST if you argue long enough.

10

u/SilverBullet78SB 19d ago

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

2

u/FabioTheFox 17d ago

There is a fairly large computer hardware store in Germany that does exactly this kind of bs

I was in disbelief when I took a peek at their apps traffic

7

u/Mad-chuska 19d ago

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

17

u/Eptalin 19d 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 19d ago

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

1

u/blckshdw 17d ago

Doubt that. They’re different use cases

21

u/granadesnhorseshoes 18d 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.

14

u/rbbdk 18d 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.

2

u/Beli_Mawrr 18d 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?

3

u/pr0ghead 17d ago

So you don't have to look at the payload, which could be anything. Pretty obvious, innit?

1

u/blckshdw 17d ago

>But I don't understand why, for example, DELETE needs to exist

To, I don’t know, DELETE resources…

>So why not just have POSTs and encode everything in the query anyway?

Because DELETE exists? It’s for deleting resources. When you say ‘encode everything in the query’ do you mean the URL? cause that would be a GET. You don’t really use query parameter with POST since you’re sending a body.

0

u/Beli_Mawrr 17d ago

I can code 15 endpoints, 5 of which are the basic html actions, the other 10 of which are basically posts with the verb encoded in the body, or I can just skip the middle steps and do all 15 as a post. You see what I mean? Its usually way more difficult and confusing to make a bunch of handlers for POST, DELETE, UPDATE, GET etc than it is to make one and put the handling logic in the function 

1

u/blckshdw 17d ago edited 17d ago

No I don’t see what you mean. The verb doesn’t go in the body. It’s part of the headers to the server, quite literally the first command sent to the server is VERB /path Whatever

Whatever you’re doing, you’re doing it the wrong. There’s no more effort in declaring DELETE or PATCH over POST.

If you need a referrer on the fundamentals try here. https://howhttpworks.com/guides/how-http-works

1

u/LogicBalm 18d ago

Yeah I have to "code" in a "low code" environment for work and they didn't even implement anything besides GET and POST. And GET is often too erratic in their system. It also returns an API failure if the return values aren't exactly as the system expects, even if the API returned 200. All we get back is a success or fail so it's not like we could actually read an error. We have to go to the far sides developers and ask them what the result of our test was. It's a nightmare. Once it works, never touch it.

10

u/Kuzame 18d ago

She would like to have a word with you..

5

u/kratz9 19d ago

Anyone remember WebDAV?

3

u/pr0ghead 18d ago

Or SOAP?

9

u/overclockedslinky 18d 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)

7

u/GumboSamson 18d ago

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

6

u/Zeenu29 18d ago

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

1

u/DeiviiD 18d ago

It’s out?

4

u/Sometimesiworry 18d ago

It is but not adopted by all webkits yet iirc

3

u/AyrA_ch 18d 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())

3

u/Kitchen_Affect7369 18d ago

Where is GET? And use GET for post data?

3

u/torftorf 18d ago

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

2

u/distortedsignal 19d ago

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

2

u/NexusDarkshade 18d ago

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

2

u/migarma 18d ago

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

2

u/No-Magazine-2739 18d ago

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

2

u/DrTight 18d ago

We have everything as POST and GET /deleteUser Horrible API

2

u/TrackLabs 18d 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?

2

u/xgabipandax 18d 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

2

u/FoxedDev 18d ago

IT'S QUERY TIME

2

u/atehrani 18d ago

GraphQL

2

u/tehtris 17d ago

I'm working with an API that only has posts. Everything is a post. This means a separate endpoint for every crud operation of every object. CreateCustomer, UpdateCustomer, DeleteCustomer, GetCustomer. All posts. It's such a dumb API it even goes further. There's shit like UpdateCustomerPhoneNumber.

It makes me want to quit my job, get hired by them and fix their API, quit that job and then become a beet farmer.

3

u/Tackgnol 18d ago

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

So this was company policy.

2

u/Puzzleheaded-Weird66 19d ago

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

1

u/FabioTheFox 17d ago

Normalize having handler funcs that take your form data and creates a json payload for a proper http request, the form stuff has always been nonsense

2

u/Honest_Relation4095 18d 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").

1

u/arran4 18d ago

It should all be PUT. 

1

u/Ravens_Quote 18d ago

So no head?

1

u/jbaker88 18d 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/Ledeste 18d ago edited 18d ago

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

Reading the comments I feel so safe in my job x) as long as most people do not even understand why you should NOT use anything else than POST, there will be shitty legacy to remake :D

1

u/pxoqxo 18d ago

Someone told me post is most secured method. And now my all data gonna secure.

1

u/GoddammitDontShootMe 18d ago

When does anyone ever use anything that isn't GET or POST? This is the first I've even heard of PATCH.

1

u/fearthelettuce 17d ago

Why do people allow this?

1

u/darcygravan 16d ago

Http is over engineered.

-4

u/pjkm123987 19d 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 19d 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.

4

u/lampishthing 19d 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.

0

u/swagwise_gamgee 18d ago

GraphQL 😎

-2

u/highcastlespring 19d ago

GET is not safe. POST encrypts your parameters.

PUT, the right way, but no one uses

1

u/FabioTheFox 17d ago

GET is not safe?

Does your api look like this? /api/auth/login?email=example@example.com&password=123456

By any chance?

1

u/highcastlespring 17d ago

Pretty sure this happens many times in many college http projects, and some outsourcing website

-1

u/NebraskaGeek 18d ago

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

-2

u/cecil721 19d ago

Bro forgot QUERY exists now