r/ProgrammerHumor • • 25d ago

Meme everythingGoesIntoThePostHole

Post image
4.4k Upvotes

153 comments sorted by

159

u/PatienceLost9708 25d ago

the other methods are just for the technical interview

50

u/darad55 25d ago

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

27

u/GigaGollum 25d ago

Replace HEAD with QUERY pls

12

u/darad55 25d ago

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

4

u/JebKermansBooster 25d ago

That's what she said

4

u/darad55 25d ago

I don't think she needed extra holes

1

u/JebKermansBooster 25d ago

Never know. Maybe she's a nympho?

0

u/gilium 24d ago

None of us in this sub will be receiving HEAD

5

u/Effective-Bill-2589 25d ago

I'm guilty of this

4

u/darad55 25d ago

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

1

u/RepresentativeCat553 24d ago

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

-1

u/RAMChYLD 25d 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).

870

u/SirChasm 25d 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 25d 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 24d 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 24d 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 25d 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 25d ago • Bravo

“A union of success and failure”

Unreasonably poetic lmao

17

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

php code is like this

7

u/teddy5 25d 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 25d ago

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

9

u/teddy5 25d 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 24d 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 11d ago

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

1

u/DTCreeperMCL6 24d 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 23d ago

1

u/DTCreeperMCL6 23d ago

I dont know I just enjoy it lol

3

u/ScallionSmooth5925 25d ago

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

2

u/Drego3 24d ago

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

0

u/Beli_Mawrr 24d 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 25d ago

Traumatised by graphql

20

u/rumnscurvy 25d 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 25d ago

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

7

u/octatone 25d ago

Thank you GraphQL

13

u/razzemmatazz 25d ago

sees the JS in your flair

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

9

u/ATE47 25d ago

Error codes is for losers

return "the request failed"

2

u/CardOk755 25d ago

I mostly get error 500 from shitty apps.

4

u/usedToBeUnhappy 24d 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 25d ago

This thread is giving me a twitch

3

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

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

13

u/StaticCoder 25d 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 25d ago

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

5

u/Angoulor 25d 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 24d 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 23d 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 23d 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 23d 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] 25d ago

[deleted] — view deleted comment

0

u/StaticCoder 24d 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] 24d ago

[deleted] — view deleted comment

1

u/StaticCoder 23d 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 23d 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 25d ago

do you work for the IRS?

2

u/TheWb117 25d ago

You guys get error codes and not stack traces?

2

u/Traditional-Tale-372 25d ago

The error message was shown successfully: http 200

2

u/Short_Change 23d 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 23d ago

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

1

u/bloody-albatross 23d 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 23d 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 20d 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 25d 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 25d ago

I have a vendor like that

1

u/_xiphiaz 25d ago

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

1

u/Head-Bureaucrat 24d 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 23d ago

-sharpens pitchfork-

No.

1

u/Outside-House-7655 23d 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 25d 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_ 25d ago

Security by obscurity

83

u/FallenVampireLord 25d ago

Same thing my wife told me

23

u/eclect0 25d ago

Weird, she also told me that

7

u/KingVecchio 25d ago

Wtf bro she also told me!

9

u/Decoder44 25d ago

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

70

u/falcon0041 25d ago

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

86

u/queen-adreena 25d ago • Bravo

Fortunately, you have the QUERY verb now.

28

u/GumboSamson 25d 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 25d ago

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

134

u/gringrant 25d ago

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

The OPTION response:

  • OPTION
  • POST

6

u/LB-- 24d ago

Response status code 300

26

u/Desidiosus 25d 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 25d ago

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

4

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

Congrats, you invented GraphQL.

33

u/Curious_Associate904 25d 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 25d ago

Immediately, yes! I control both sides.

7

u/5up3rj 24d ago

Neat. How do you POST those?

1

u/blckshdw 23d ago

…. You QUERY them … 👀

1

u/blckshdw 23d 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 25d ago

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

11

u/TundraGon 25d ago

Anything's a POST if you argue long enough.

10

u/SilverBullet78SB 25d ago

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

2

u/FabioTheFox 24d 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 25d ago

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

17

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

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

1

u/blckshdw 23d ago

Doubt that. They’re different use cases

21

u/granadesnhorseshoes 25d 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 25d 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 24d 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 24d ago

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

1

u/blckshdw 23d 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 23d 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 23d ago edited 23d 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 24d 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 25d ago

She would like to have a word with you..

5

u/kratz9 25d ago

Anyone remember WebDAV?

3

u/pr0ghead 25d ago

Or SOAP?

9

u/overclockedslinky 25d 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 25d ago

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

6

u/Zeenu29 25d ago

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

1

u/DeiviiD 25d ago

It’s out?

4

u/Sometimesiworry 25d ago

It is but not adopted by all webkits yet iirc

3

u/AyrA_ch 25d 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 25d ago

Where is GET? And use GET for post data?

3

u/torftorf 24d 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 25d ago

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

2

u/NexusDarkshade 25d ago

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

2

u/migarma 25d ago

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

2

u/No-Magazine-2739 25d ago

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

2

u/DrTight 24d ago

We have everything as POST and GET /deleteUser Horrible API

2

u/TrackLabs 24d 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 24d 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 24d ago

IT'S QUERY TIME

2

u/atehrani 24d ago

GraphQL

2

u/tehtris 24d 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 25d ago

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

So this was company policy.

2

u/Puzzleheaded-Weird66 25d ago

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

1

u/FabioTheFox 24d 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 25d 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 25d ago

It should all be PUT. 

1

u/Ravens_Quote 25d ago

So no head?

1

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

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

1

u/GoddammitDontShootMe 24d 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 24d ago

Why do people allow this?

1

u/darcygravan 22d ago

Http is over engineered.

-4

u/pjkm123987 25d 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 25d 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 25d 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 25d ago

GraphQL 😎

-2

u/highcastlespring 25d ago

GET is not safe. POST encrypts your parameters.

PUT, the right way, but no one uses

1

u/FabioTheFox 24d 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 24d ago

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

-1

u/NebraskaGeek 25d 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 25d ago

Bro forgot QUERY exists now