Live data from Hacker News

You know how HTTP GET requests are meant to be idempotent?

twitter.com

131–140 of 313 posts

Re: You know how HTTP GET requests are meant to be idempotent?

#131
post #98
post #95

Earlier quoted context omitted.

Your desk runs a web server? I need to step up my game...

Yeah, it's a sit/stand Linak desk. I hooked up an ESP32, 2 channel relay (up/down control), and distance sensor (to detect height). Pushes height to graphite and position is settable remotely. :)

It's been an hour, is your desk oscillating yet?

Re: You know how HTTP GET requests are meant to be idempotent?

#132
post #116

Earlier quoted context omitted.

Having a single confirmation step to prevent "oops" clicks doesn't seem like a dark pattern to me.

The majority of people who clicked on the link did it on purpose, so a better pattern would be to make it unsubscribe immediately with a "didn't meant to unsubscribe? click here to undo" link afterwards.

You're making the mistake that this very article is highlighting: it's not just "people" who click links. An overzealous mail client or browser preloading links would force unsubscribe you without your knowledge or ability to undo.

A single step, a button push, to confirm an unsubscription is fine.

Re: You know how HTTP GET requests are meant to be idempotent?

#133
post #59

Earlier quoted context omitted.

This still seems like really bad idea when the POST request is right there. Serve a page with a button saying "are you sure"?

Do you really like having to confirm every action? For interfaces that you use all the time, it's nice to be able to eliminate extra steps.

Every action? No. Rebooting a machine, however?

Re: You know how HTTP GET requests are meant to be idempotent?

#134

Earlier quoted context omitted.

Having a single confirmation step to prevent "oops" clicks doesn't seem like a dark pattern to me.

Have a single "I clicked by mistake" button that resubscribes instead.

Yes, the automated system prefetching links will always click said button.

Re: You know how HTTP GET requests are meant to be idempotent?

#135

Earlier quoted context omitted.

Having a single confirmation step to prevent "oops" clicks doesn't seem like a dark pattern to me.

Confirmation steps should only be used if the action can't be easily undone.

And when a user receives an email saying they've been unsubscribed because an automated system prefetched the link, they won't be concerned or worried or confused at all. (Especially when this happens _every time_.

Re: You know how HTTP GET requests are meant to be idempotent?

#136
post #29

Hello! Long-time lurker, and guilty dev behind the garage door. You can see the (broken) code I wrote here: https://github.com/wpearse/wemos-d1-garage-door-wifi I'll get around to fixing it later this week. Also, an apology: I should have used "side-effect-free" instead of "idempotent" in my tweets.

> I should have used "side-effect-free" instead of "idempotent" in my tweets The HTTP term is "safe method". Although you weren't even wrong because section 4.2.2 of RFC7231 (i.e. HTTP) defines all safe methods, including GET, as idempotent. I think they use this language because nothing is truly side-effect free. In fact GETs can have side-effects, the most obvious of which is writing the fact of it to a logfile, an…

'Side-effect free' means that doing it once, twice or n >= 3 times (with same parameters) yields the same result, i.e. what it returns doesn't depend on any remote state that is altered by the call itself.

However, an idempotent HTTP call is certainly not a pure function which some people seem to be mixing up. Pure functions don't work with I/O.

REST is bit more specific and explicitly requires GET to be nullipotent which really means "effect free" - it just reads and doesn't alter the state on the remote system at all.

Side-effects like log files, rate-limiting, etc. will always exist, but they do belong to a different 'layer', so to speak. That is, these should be unobservable side-effects (also think about minuscule effects on the power grid, the fact that a request might write something to an ARP-cache, etc. - they all happen at different layers, so the quantum world state keeps changing, but that's not what this is about). Whether an X-Request-Count header violates the requirements or not depends on interpretation. From the garage door perspective, I wouldn't care...

Re: You know how HTTP GET requests are meant to be idempotent?

#137
post #15

When I recently added 'click to unsubscribe' functionality to my emails, the URL got wrote out into some logs. Those logs got written to a Slack channel and Slack loves to click any link it sees. Oh, and it doesn't respect robots.txt. But all I saw was every member of my list clicking 'unsubscribe'. It took a good hour to figure out exactly what was going on. Idempotence is not the problem here, by the way. That just…

If the unsubscribe link were unique for each subscriber would the law still be satisfied?

I don't understand how that prevents an automated system from unsubscribing them?

Re: You know how HTTP GET requests are meant to be idempotent?

#138
post #34
post #32

Earlier quoted context omitted.

“Toggle” is by definition not idempodent, because you get a different result each and every time. “Open” and “close” are idempodent, but not safe. The result of a GET request should always be idempodent and safe.

GET requests should have no side effects. In other words NOOP is idempotent

Get should be safe, but that's not the same as indempotent. Delete requests are also indempotent as the final state will always be the same.

Re: You know how HTTP GET requests are meant to be idempotent?

#139
post #15

When I recently added 'click to unsubscribe' functionality to my emails, the URL got wrote out into some logs. Those logs got written to a Slack channel and Slack loves to click any link it sees. Oh, and it doesn't respect robots.txt. But all I saw was every member of my list clicking 'unsubscribe'. It took a good hour to figure out exactly what was going on. Idempotence is not the problem here, by the way. That just…

If the unsubscribe link were unique for each subscriber would the law still be satisfied?

I thought that initially, but then I considered that for users to be bulk unsubscribed then the link would surely have to be the same for every user, at which point the each user gets the same unsubscribe link, and then when they click on it it unsubscribes everyone.

This doesn't seem very likely, so I guess that a whole load of unique unsubscribe links got dumped into slack which started following them.

Re: You know how HTTP GET requests are meant to be idempotent?

#140

Earlier quoted context omitted.

What would the problem be in just showing a button that says "Confirm unsubscribe" that sends a POST request? A lot of sites does something like that for their newsletter unsubscription.

I like the one-click URLs though. It irritates me to no end to click unsub, then wait for a page to load then repeat my intention.

I'm actually much more concerned when I don't have to click the link. It let's me know they haven't thought the problem through and what other errors and problems are there in their systems?
Post reply on HN