<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Idempotency on Brian Faust</title><link>https://vacua.dev/tags/idempotency/</link><description>Recent content in Idempotency on Brian Faust</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate><atom:link href="https://vacua.dev/tags/idempotency/rss.xml" rel="self" type="application/rss+xml"/><item><title>A Code Review Should Test the Decision, Not the Author</title><link>https://vacua.dev/thoughts/a-code-review-should-test-the-decision-not-the-author/</link><pubDate>Thu, 01 Aug 2019 00:00:00 +0000</pubDate><guid>https://vacua.dev/thoughts/a-code-review-should-test-the-decision-not-the-author/</guid><description>&lt;p&gt;One booking flow could trigger the same automatic wallet refill twice. The
first refill happened while booking. A later debit event ran the ordinary
refill check again.&lt;/p&gt;
&lt;p&gt;The retained correction wrote a short-lived marker per account containing the
pending amount. When a matching shipment debit arrived, it consumed the marker
and skipped one refill. Focused tests covered the expected sequence.&lt;/p&gt;
&lt;p&gt;That is enough to begin a review, not finish one. The decision is not “is this
cache helper elegant?” It is:&lt;/p&gt;</description></item><item><title>An Idempotency Key Is Not an Identity</title><link>https://vacua.dev/thoughts/an-idempotency-key-is-not-an-identity/</link><pubDate>Fri, 01 Jun 2018 00:00:00 +0000</pubDate><guid>https://vacua.dev/thoughts/an-idempotency-key-is-not-an-identity/</guid><description>&lt;p&gt;A booking test sends the same request twice with the same idempotency key. The
remote booking service is called once. Both callers receive the same successful
response.&lt;/p&gt;
&lt;p&gt;Then one field changes while the key stays the same. The remote service is
still called once, but the second request receives a conflict instead of the
first result.&lt;/p&gt;
&lt;p&gt;The key did not establish sameness. It only gave the application somewhere to
look.&lt;/p&gt;</description></item><item><title>A Webhook Delivery Is Not a Unique Event</title><link>https://vacua.dev/thoughts/a-webhook-delivery-is-not-a-unique-event/</link><pubDate>Tue, 01 May 2018 00:00:00 +0000</pubDate><guid>https://vacua.dev/thoughts/a-webhook-delivery-is-not-a-unique-event/</guid><description>&lt;p&gt;A subscription callback had already created this local record:&lt;/p&gt;
&lt;figure class="code-figure"&gt;
 &lt;div class="code-block" data-copy-code&gt;
 &lt;button class="copy-code" type="button" aria-label="Copy code"&gt;copy&lt;/button&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;carrier: external-freight
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;subscription_id: sub-demo-17
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;secret: old-secret
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;expires_at: 2018-05-08T12:00:00Z&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
 &lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;The sender delivered another validation message for &lt;code&gt;sub-demo-17&lt;/code&gt;, now with a
new secret and expiry. The handler tried to insert a second row. A unique
constraint rejected it, so the activation step never ran.&lt;/p&gt;
&lt;p&gt;The database was right. The handler had mistaken another delivery for another
subscription.&lt;/p&gt;
&lt;h2 id="start-with-the-identity-the-sender-repeated"&gt;Start with the identity the sender repeated&lt;/h2&gt;
&lt;p&gt;A webhook request is evidence that a message was delivered. It is not evidence
that this message has never arrived before.&lt;/p&gt;</description></item></channel></rss>