<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tdude</title>
    <description>The latest articles on DEV Community by Tdude (@tdude).</description>
    <link>https://dev.to/tdude</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4206206%2F3bda2a84-3507-497f-91b1-1c3252535469.jpg</url>
      <title>DEV Community: Tdude</title>
      <link>https://dev.to/tdude</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tdude"/>
    <language>en</language>
    <item>
      <title>Don't let nginx do your app's homework</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Sat, 14 Nov 2026 09:02:52 +0000</pubDate>
      <link>https://dev.to/tdude/dont-let-nginx-do-your-apps-homework-2m3b</link>
      <guid>https://dev.to/tdude/dont-let-nginx-do-your-apps-homework-2m3b</guid>
      <description>&lt;p&gt;&lt;em&gt;The bouncer at the front door is great, as long as nobody comes in through the kitchen.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I was getting a sign-in flow ready to give away as an npm package. The sign-in links you get by email, no password. Before handing code to strangers, I wanted to know what it trusts.&lt;br&gt;
The answer, in more places than I liked: nginx.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; A reverse proxy in front of your app quietly does security work:&lt;br&gt;
it sets the visitor's real address, strips forged headers, and makes rate limits per visitor mean something. &lt;br&gt;
&lt;strong&gt;Why it matters.&lt;/strong&gt; Code that only works safely behind &lt;em&gt;your&lt;/em&gt;&lt;br&gt;
proxy is not safe code. Someone runs it without one. Or adds a second hop. Or copies it into a project with a different setup. Then every one of those quiet guarantees is gone, and nothing fails loudly.&lt;/p&gt;

&lt;p&gt;So here are the checks, one per thing your proxy might be doing for you without telling you. Ok, it gets a bit technical, but just skim over it to get the gist.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. One place decides who the visitor is
&lt;/h2&gt;

&lt;p&gt;Per-IP rate limits only work if the IP is real. Behind nginx, &lt;code&gt;X-Forwarded-For&lt;/code&gt; is overwritten, so it is real. Without nginx it is whatever the visitor typed. A new fake address on every request, and the limit never trips.&lt;/p&gt;

&lt;p&gt;The fix is one rule: &lt;strong&gt;one component resolves the visitor address, and every hop below it overwrites the headers instead of copying them.&lt;/strong&gt; In SvelteKit that component is&lt;br&gt;
&lt;code&gt;event.getClientAddress()&lt;/code&gt;, which adapter-node bases on &lt;code&gt;ADDRESS_HEADER&lt;/code&gt; (set it behind a&lt;br&gt;
proxy that overwrites the header; leave it unset when the app faces the internet directly).&lt;br&gt;
When the app calls a backend on the visitor's behalf:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Headers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'x-real-ip'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'x-forwarded-for'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'forwarded'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'host'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'connection'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getClientAddress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'X-Real-IP'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'X-Forwarded-For'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copying the browser's headers along "to be helpful" is the bug. Most proxy code does exactly that.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. A backend believes the header only from a hop it knows
&lt;/h2&gt;

&lt;p&gt;The backend gets the other half of the rule. A forwarded address counts only when the request came from inside your own network. From anyone else, the socket address is the truth.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ipaddress&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;client_ip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;peer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;real_ip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;internal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ipaddress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ip_address&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;peer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;internal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;internal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_private&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;internal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_loopback&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;internal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;real_ip&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;peer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;internal&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;peer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A gotcha for your tests: Python counts the documentation ranges (&lt;code&gt;203.0.113.0/24&lt;/code&gt; and friends) as &lt;em&gt;private&lt;/em&gt;. Test a "public" peer with an address that really is public, or your test proves the opposite of what you think.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Rate limits live where every process can see them
&lt;/h2&gt;

&lt;p&gt;A counter in process memory looks fine on a laptop. In production it resets on every restart. And during a zero-downtime deploy two copies of the app run at once, each with its own budget. So an attacker gets twice the tries exactly when you're busy watching the deploy.&lt;/p&gt;

&lt;p&gt;Put the hits in the database you already have. One row per attempt, one transaction per check, and a lock per key so two requests can't both read "9" and both insert the 10th:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="nf"&gt;pg_advisory_xact_lock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;hashtext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;login_attempts&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;key&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;hit_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="kt"&gt;interval&lt;/span&gt; &lt;span class="s1"&gt;'60 seconds'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) FROM login_attempts WHERE key = :key;   -- at the limit: 429
INSERT INTO login_attempts (key, hit_at) VALUES (:key, now());
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the database is down, refuse with a 503. A limiter that fails open is just a suggestion.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Check redirect targets the way the browser reads them
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;?next=/somewhere&lt;/code&gt; after sign-in is handy. The usual check is "starts with &lt;code&gt;/&lt;/code&gt; and not &lt;code&gt;//&lt;/code&gt;". Now try &lt;code&gt;/\t/evil.example&lt;/code&gt;, with a tab character after the first slash. The string check passes. The browser strips tabs and newlines while it parses the URL, sees &lt;code&gt;//evil.example&lt;/code&gt;, and leaves your site.&lt;/p&gt;

&lt;p&gt;Don't out-think the parser. Use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'http://same-origin.invalid'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;safeNext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;\&lt;span class="n"&gt;u0000&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;\&lt;span class="n"&gt;u001f&lt;/span&gt;\&lt;span class="n"&gt;u007f&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;BASE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No proxy helps you here, by the way. That one is all yours.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Keep tokens out of the places that write things down
&lt;/h2&gt;

&lt;p&gt;A sign-in token in &lt;code&gt;?token=&lt;/code&gt; lands in every access log between the mail and your app, plus browser history and any link preview a scanner fetches. Put it in the fragment instead: &lt;br&gt;
&lt;code&gt;/signin#token=…&lt;/code&gt;. Browsers never send the part after &lt;code&gt;#&lt;/code&gt; to a server. The page reads it, strips it from the address bar, and spends it with a POST, so a mail scanner that "clicks" the link doesn't sign anyone in. Add &lt;code&gt;Referrer-Policy: no-referrer&lt;/code&gt;&lt;br&gt;
and &lt;code&gt;Cache-Control: no-store&lt;/code&gt; to that page for good measure.&lt;/p&gt;

&lt;h2&gt;
  
  
  The test that finds all of this
&lt;/h2&gt;

&lt;p&gt;Run the app with the proxy switched off, and attack it. Send twelve sign-in attempts, each with a new forged &lt;code&gt;X-Forwarded-For&lt;/code&gt;. If the twelfth isn't refused, your limit belongs to nginx, not to you.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we changed, and the other ways to do it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The visitor address:&lt;/strong&gt; one component resolves it, every hop overwrites it, and backends trust it only from internal peers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate limits:&lt;/strong&gt; from process memory to a database table with a lock per key, closed on   failure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redirects:&lt;/strong&gt; from string checks to the URL parser, with control characters refused.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sign-in tokens:&lt;/strong&gt; from the query string to the fragment, spent only by POST.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other ways work too. &lt;strong&gt;A fixed list of trusted proxy addresses&lt;/strong&gt; (what most frameworks call "trusted proxies") is stricter than "any private address". But you have to keep it right every time the network changes. &lt;strong&gt;Redis for the limiter&lt;/strong&gt; is faster and has expiry built in. But it's one more service to run and to secure, and for sign-in traffic a table is plenty.&lt;br&gt;
&lt;strong&gt;Signed headers between hops&lt;/strong&gt; (an HMAC over the forwarded address) survive even a compromised neighbour on the network. But every hop needs the key, and that's real work.&lt;/p&gt;

&lt;p&gt;Pick the cheapest one that still holds when the proxy is gone.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/dont-let-nginx-do-your-apps-homework" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>selfhosting</category>
    </item>
    <item>
      <title>Show the window, keep the back room shut</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Tue, 10 Nov 2026 14:53:20 +0000</pubDate>
      <link>https://dev.to/tdude/show-the-window-keep-the-back-room-shut-209j</link>
      <guid>https://dev.to/tdude/show-the-window-keep-the-back-room-shut-209j</guid>
      <description>&lt;p&gt;A shop window shows what's for sale. The back room holds the invoices, the keys and the staff rota. Nobody minds the back room existing, as long as the door stays shut.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; A web page works the same way, except its door is easy to leave ajar without noticing. This post is about how I decide what a page hands out, and about timing: what a small site can leave for later, what it can't, and what happens to a plan when nobody is watching it.&lt;/p&gt;

&lt;h2&gt;
  
  
  A page carries more than it shows
&lt;/h2&gt;

&lt;p&gt;Modern sites send the page and its data together, so the page can come alive in the browser without asking the server again. That's fast and pleasant. It also means that whatever the page was given travels with it, even the parts nothing on screen ever uses. Open the page source and it's all there.&lt;/p&gt;

&lt;p&gt;So the useful question isn't "what does the page show?" It's "what did we hand it?" Those two drift apart quietly. A field gets added for the editor, the public page reuses the same loader, and now every visitor receives a value only the editor needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two audiences, two shapes
&lt;/h2&gt;

&lt;p&gt;The cheapest way to build a page is to pass the stored record straight through. One shape, used everywhere. It works until you notice that the editor and the visitor want very different things.&lt;/p&gt;

&lt;p&gt;An editor needs the whole record: who created it, when it goes offline, where it sits in the menu. A visitor needs a headline, the text, a date and a byline. So now there are two shapes. Staff get the full one. Visitors get what the page renders, and the fields only the editor uses come out empty.&lt;/p&gt;

&lt;p&gt;The byline was the nice part. A post shows who wrote it and, on some sites, a little badge. The badge used to be built from the author's account role, which meant the page carried the role itself. Now it carries a label made for readers, "crew" or "HQ", and nothing about the account behind it. Same badge on screen, less in the source.&lt;/p&gt;

&lt;h2&gt;
  
  
  Size decides when, not whether
&lt;/h2&gt;

&lt;p&gt;These sites have few users, and only one takes payments. So payments and logins came first, and what a public page carries came after. On a small site that's housekeeping, not a fire.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Had it been bigger sites, of course this must be addressed already in the plan.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With many accounts and money moving, the visitor shape belongs on the first sketch, next to the database tables. A small site buys time. It doesn't buy an exemption.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plans drift
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;I think there actually was a plan but it drifted.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There was. Then features arrived one at a time, each adding a field "for now", each harmless on its own. Drift makes no noise, so something has to listen for it: a second pair of eyes on the page source, and tests that read a page the way a visitor gets it and fail the day it carries an editor-only field. The plan was written once. The tests run on every change.&lt;/p&gt;

&lt;h2&gt;
  
  
  The browser as bouncer
&lt;/h2&gt;

&lt;p&gt;The browser can guard the door too. A content policy is a short list the page sends along: which scripts may run, where things may load from. Anything not on the list stays outside.&lt;/p&gt;

&lt;p&gt;You don't hire the bouncer blind. First he only reports who he would have turned away, and you read the reports: the video embed you forgot, the payment widget, a script your own framework writes inline. When the complaints go quiet, he gets to say no. Skip the listening and he throws out your own checkout on a Friday.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, and how else it could be done
&lt;/h2&gt;

&lt;p&gt;Visitors got the editor's record because one shape was the easy default. Now they get a public shape, staff keep the full one, the badge is a reader's label, and tests fail if the public shape grows. Every site also sends a content policy that listens first.&lt;/p&gt;

&lt;p&gt;Other ways: list what goes in instead of what comes out, so a new field stays private until someone says otherwise. Safer, but every new feature costs a decision. A separate public API makes the split impossible to forget, and doubles the upkeep. Or do nothing for a while, which is fine as long as it's a choice and not drift.&lt;/p&gt;

&lt;p&gt;Back rooms fill up on their own. Windows you dress on purpose.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/what-the-page-shows" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>ux</category>
    </item>
    <item>
      <title>The free trial is a bet on your memory</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Sun, 08 Nov 2026 15:50:06 +0000</pubDate>
      <link>https://dev.to/tdude/the-free-trial-is-a-bet-on-your-memory-1bjg</link>
      <guid>https://dev.to/tdude/the-free-trial-is-a-bet-on-your-memory-1bjg</guid>
      <description>&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; Almost every tool I try, and AI and developer tools most of all, wants a card number before the "free" part starts. &lt;em&gt;This was called Fraud a few years ago and pornsites used it all the time (you should know :).&lt;/em&gt; Now, the company is betting that day 15, or whatever, arrives before I remember and it is just called business as usual. Here's how to make that bet lose, and where the popular tricks quietly fail.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I hereby declare WAR on Darketing!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Why.&lt;/strong&gt; The tricks that circulate online are just half right. A declined card doesn't end a contract, and cancelling on day one sometimes ends the trial on day one too.&lt;/p&gt;

&lt;h2&gt;
  
  
  The card that says no
&lt;/h2&gt;

&lt;p&gt;The favourite trick is a virtual card with a tiny limit. Privacy.com in the US, or a disposable card from Revolut in Europe. When the trial converts, the billing robot knocks, the card says no, and nothing happens. Nice.&lt;/p&gt;

&lt;p&gt;Three catches, though:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Privacy.com is US-only.&lt;/strong&gt; It needs a US bank account. Outside the US you're looking at your own bank's virtual cards, Revolut, or similar.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A disposable card dies by design.&lt;/strong&gt; Revolut's disposable card gets new details after every successful payment, so it can't carry a subscription at all. Fine for a trial, useless the day you actually want to pay.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A refused payment isn't a cancellation.&lt;/strong&gt; The contract you clicked "agree" on is still there. The company can retry, suspend your account, or send you a bill. Most won't chase you for one month of a $20 tool, but some do, and an unpaid invoice is a worse souvenir than a charge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the burner card is a seatbelt, not the brakes. Use it, and cancel anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cancel on day one, but read the screen first
&lt;/h2&gt;

&lt;p&gt;The other classic: sign up, then go straight to settings and cancel. Lots of services let you keep the remaining days. Apple's App Store and Google Play both keep a cancelled trial running to the end.&lt;/p&gt;

&lt;p&gt;Not everyone plays along. Spotify ends Premium the moment you cancel a free trial, in most countries. Apple's own Music and TV+ trials have done the same in some places. Nothing in the law says you get to keep the rest of the days. It's the company's choice.&lt;/p&gt;

&lt;p&gt;The cancel screen almost always tells you. If it says access ends now, back out, and put a reminder in your calendar two days before the charge instead. Two days, not one: time zones and "billing runs at midnight" have eaten many a last-day cancel.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the rules already say
&lt;/h2&gt;

&lt;p&gt;You have more on your side than the trial page suggests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visa&lt;/strong&gt; has required since April 2020 that a merchant sends you an email or text at least seven days before the first charge after a trial, with a way to cancel online, and that the first charge says "trial" on your statement (&lt;a href="https://usa.visa.com/content/dam/VCOM/global/support-legal/documents/visa-new-subscription-rules-flier.pdf" rel="noopener noreferrer"&gt;Visa's rules&lt;/a&gt;). Mastercard has similar trial rules. No reminder email? Tell your bank when you dispute the charge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the EU,&lt;/strong&gt; you get 14 days to withdraw from an online contract, and since &lt;strong&gt;19 June 2026&lt;/strong&gt; online shops must give you a withdrawal button to do it. But the EU Court of Justice ruled in 2023 that a trial which turns into a paid subscription gives you that right &lt;strong&gt;once&lt;/strong&gt;, at sign-up, as long as you were told the full price then (&lt;a href="https://curia.europa.eu/jcms/upload/docs/application/pdf/2023-10/cp230154en.pdf" rel="noopener noreferrer"&gt;the ruling&lt;/a&gt;). The conversion doesn't restart the clock. Germany and France already require a plain cancel button, and the EU's coming Digital Fairness Act takes aim at subscription traps more broadly. In Sweden, where I live, the consumer authorities' line is that cancelling must be &lt;em&gt;at least as easy as signing up&lt;/em&gt;. Very fuzzy and typical Swedish imho.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the US,&lt;/strong&gt; the FTC's "click to cancel" rule was struck down in July 2025, on procedure rather than principle, and the FTC started over in 2026. Enforcement didn't wait: Amazon agreed in September 2025 to pay $2.5 billion over Prime sign-ups and cancellations (&lt;a href="https://axios.com/2025/09/25/amazon-prime-ftc-settlement" rel="noopener noreferrer"&gt;Axios&lt;/a&gt;), and Adobe settled its case over early-cancellation fees in March 2026. Several states, California among them, have their own easy-cancel laws.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the UK,&lt;/strong&gt; a new subscription regime starts in January 2027, with reminders before a trial ends and a cooling-off period at renewal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Or skip the bet
&lt;/h2&gt;

&lt;p&gt;The best trial is the one that never needs a card. More and more of what I'd otherwise rent, I run myself. My sites serve their own fonts instead of borrowing Google's, and count their own visitors instead of renting a dashboard. Open-source AI models run on an ordinary computer now, and for a lot of everyday work they're good enough.&lt;/p&gt;

&lt;p&gt;Self-hosting isn't free either. You pay in time, in updates, and in the evening when something breaks and there's no support desk to email. It pays off for things you use every day. For a tool you want to test for an afternoon, the burner card and a calendar reminder are cheaper.&lt;/p&gt;

&lt;h2&gt;
  
  
  What works, and what each costs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A trial that bills by default.&lt;/strong&gt; Beat it with a calendar reminder two days early, not one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cancelling ends the trial at once.&lt;/strong&gt; Read the cancel screen; if it says "now", set the reminder instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A charge you never expected.&lt;/strong&gt; No seven-day reminder breaks Visa's rules. Dispute it with your bank.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Being locked in for good.&lt;/strong&gt; Self-host what you use daily, and pay in time instead of money.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Better at&lt;/th&gt;
&lt;th&gt;Costs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Burner or disposable card&lt;/td&gt;
&lt;td&gt;Stops the surprise charge cold&lt;/td&gt;
&lt;td&gt;Doesn't end the contract; can't pay for real later&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cancel on day one&lt;/td&gt;
&lt;td&gt;No charge, no reminder needed&lt;/td&gt;
&lt;td&gt;Some services end the trial immediately&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Calendar reminder&lt;/td&gt;
&lt;td&gt;Works everywhere, keeps every trial day&lt;/td&gt;
&lt;td&gt;Only as good as your calendar habit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Subscribe through Apple or Google&lt;/td&gt;
&lt;td&gt;One place to see and cancel everything&lt;/td&gt;
&lt;td&gt;Some apps cost more there&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Self-hosting or open source&lt;/td&gt;
&lt;td&gt;No bill, your data stays home&lt;/td&gt;
&lt;td&gt;Your time, your server, your problem&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Rule of thumb: the company bets on your memory, so don't use your memory. Use a calendar, and a card that can say no.&lt;/p&gt;

&lt;p&gt;Got any more tricks? Shout in the comments. Refuse DARKETING!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/the-free-trial-is-a-bet-on-your-memory" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>marketing</category>
      <category>privacy</category>
      <category>darketing</category>
    </item>
    <item>
      <title>I blamed the drawing</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Sun, 08 Nov 2026 12:01:20 +0000</pubDate>
      <link>https://dev.to/tdude/i-blamed-the-drawing-210j</link>
      <guid>https://dev.to/tdude/i-blamed-the-drawing-210j</guid>
      <description>&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; I run a small t-shirt design lab on my own sites. You pick a drawing, pick an ink colour, and it prints. Two of my own designs refused to take any colour at all. This is the hunt: two genuine problems in the artwork that turned out not to be the cause, and the real one hiding in a function call that one of my two upload routes forgot to make.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why.&lt;/strong&gt; Vector files are not one thing. The same SVG means different things to Illustrator, to a browser, and to whatever pipeline you built, and all three can be confidently different at once. If you ever process user-uploaded artwork, the ending of this story is the bit to steal.&lt;/p&gt;

&lt;h2&gt;
  
  
  The complaint
&lt;/h2&gt;

&lt;p&gt;I had drawn two designs and put them in the lab. Neither would recolour. What I typed was not a bug report, it was a shrug:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"the svg I want to use has somehow ended up with grabled colors or paths overlapping. Can you clean that up or do I do it manually? In that case, what to look for?"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Reasonable assumption. I had hand-edited both files. Obviously I had broken them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Red herring one: the file with no colour at all
&lt;/h2&gt;

&lt;p&gt;The first drawing had 89 paths and not a single &lt;code&gt;fill&lt;/code&gt; anywhere. Just geometry, and an empty &lt;code&gt;&amp;lt;style&amp;gt;&amp;lt;/style&amp;gt;&lt;/code&gt; where the colours used to live.&lt;/p&gt;

&lt;p&gt;In my editor this looks like a disaster. Unfilled paths get drawn with whatever swatch is loaded, or as bare outlines. That was the "garbled, overlapping" look that sent me hunting in the first place.&lt;/p&gt;

&lt;p&gt;In a browser it looks perfect, because the SVG spec says a shape with no fill is &lt;strong&gt;black&lt;/strong&gt;. Same file, two programs, two completely different pictures, neither of them wrong.&lt;/p&gt;

&lt;p&gt;My pipeline agreed with the browser and handled it correctly. A real difference between programs, a real reason I thought it was broken, and not the bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  Red herring two: two creams
&lt;/h2&gt;

&lt;p&gt;The second drawing was broken, and this one I would never have caught by looking.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.a&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="py"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;#ede4cf&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="err"&gt;←&lt;/span&gt; &lt;span class="err"&gt;7&lt;/span&gt; &lt;span class="nt"&gt;paths&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;headline&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;kayak&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;water&lt;/span&gt;
&lt;span class="nc"&gt;.b&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="py"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;#f2eecb&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="err"&gt;←&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt; &lt;span class="nt"&gt;path&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="nt"&gt;the&lt;/span&gt; &lt;span class="nt"&gt;small&lt;/span&gt; &lt;span class="nt"&gt;line&lt;/span&gt; &lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="nt"&gt;text&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="nt"&gt;the&lt;/span&gt; &lt;span class="nt"&gt;bottom&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two colours, ten units apart out of 255. On screen they are the same cream. No human eye separates those.&lt;/p&gt;

&lt;p&gt;But recolouring in my lab is a literal text substitution: find the &lt;strong&gt;one&lt;/strong&gt; colour the drawing uses and swap in whatever ink you pick. A file naming two is treated as deliberately multicoloured and stored exactly as drawn.&lt;/p&gt;

&lt;p&gt;So one stray near-duplicate cream, on one line of text, silently demoted the whole design from "takes any ink" to "prints as-is". And as-is was cream on a white shirt, which is nothing at all.&lt;/p&gt;

&lt;p&gt;I folded &lt;code&gt;.b&lt;/code&gt; onto &lt;code&gt;.a&lt;/code&gt;. Fixed. One real defect found and repaired, and I was fairly pleased with myself.&lt;/p&gt;

&lt;h2&gt;
  
  
  It still didn't work
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"today's two vectors, this one and 'the qajaq came first' cannot change colors in the tee-lab. There must be something else in play."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There was. And the detail that cracked it was in the rest of that message:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"...the editor does not allow it, thinking it is fixed in color. Which a multi colored graphic should be"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The editor wasn't failing. It was reaching a conclusion. So the question stopped being "what is wrong with the drawing" and became "what is the editor actually looking at".&lt;/p&gt;

&lt;p&gt;It looks at the stored bytes for the literal string that marks a recolourable file. No flag, no guess. If the string isn't there, the drawing is fixed, and greying out the swatches is correct. Which meant the drawing had reached storage without ever being normalised.&lt;/p&gt;

&lt;h2&gt;
  
  
  The actual bug
&lt;/h2&gt;

&lt;p&gt;There are two ways a drawing gets into my lab, and I had written them months apart:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Route&lt;/th&gt;
&lt;th&gt;Used by&lt;/th&gt;
&lt;th&gt;Normalises the colour?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;designer upload&lt;/td&gt;
&lt;td&gt;anyone, "your uploads"&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;yes&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;admin library upload&lt;/td&gt;
&lt;td&gt;me, stocking the shared library&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;no&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One line missing, in the worse of the two places: the admin route exists &lt;em&gt;specifically&lt;/em&gt; to stock the shared library, and the whole point of a library drawing is that everyone recolours it.&lt;/p&gt;

&lt;p&gt;It survived because nothing fails. Upload returns success, the file stores, the thumbnail renders, the asset appears in the list. The only symptom is a greyed-out swatch that looks like a property of the artwork rather than a bug in the software.&lt;/p&gt;

&lt;p&gt;We had verified the conversion function worked on both my files. It did work. What we never checked, for two rounds, was whether the route I was using ever called it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, and how else it could have gone
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Drawing with no &lt;code&gt;fill&lt;/code&gt; looked broken in my editor&lt;/td&gt;
&lt;td&gt;Nothing to fix; added an explicit black so every program agrees&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Two near-identical creams made a design "multicoloured"&lt;/td&gt;
&lt;td&gt;Folded the stray colour onto the main one&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Admin library uploads never normalised at all&lt;/td&gt;
&lt;td&gt;Added the missing call, plus a test that fails without it&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The fix normalises &lt;strong&gt;at upload&lt;/strong&gt;, which is the cheapest option and matches what the other route already did. It has one real cost: it isn't retroactive. Every drawing I had already added stayed broken until I deleted and re-uploaded it.&lt;/p&gt;

&lt;p&gt;Three other ways I could have gone:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Normalise at render time.&lt;/strong&gt; Old files heal themselves and the stored file stays exactly as drawn. Costs work on every render rather than once per upload, and I render far more often than I upload.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Store both versions.&lt;/strong&gt; Most flexible, and useful if you ever want to show "as drawn". Twice the storage, two things to keep in step.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Refuse multicoloured uploads at the door.&lt;/strong&gt; Would have turned red herring two into a clear error message. Also rejects legitimately multicoloured art, which I may want later.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If I were starting again I would still normalise at upload, but I would have the editor say &lt;em&gt;why&lt;/em&gt; a drawing is fixed. "This drawing names 2 colours" would have saved the entire evening.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The rule of thumb I'm keeping:&lt;/strong&gt; when something doesn't work, confirm which code path you're actually on before you start examining the data. I checked that the function was correct. I never checked that it was being called.&lt;/p&gt;

&lt;p&gt;The lab is at &lt;a href="https://rebelkayaks.eu/tee-lab" rel="noopener noreferrer"&gt;rebelkayaks.eu/tee-lab&lt;/a&gt;, and yes, both designs take any ink now.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/i-blamed-the-drawing" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cms</category>
    </item>
    <item>
      <title>One game, many sites, no drift</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Sun, 08 Nov 2026 09:44:39 +0000</pubDate>
      <link>https://dev.to/tdude/one-game-many-sites-no-drift-4ipg</link>
      <guid>https://dev.to/tdude/one-game-many-sites-no-drift-4ipg</guid>
      <description>&lt;p&gt;&lt;em&gt;Chalk Up! was born on &lt;a href="https://vastervikbouldering.com/games/chalk-up" rel="noopener noreferrer"&gt;Västervik Bouldering&lt;/a&gt;: five granite boulders a day, a chalk bag, a beer at the top. It lived inside that site's theme, borrowing its colours, its fonts and its buttons. Then I wanted it on &lt;a href="https://rebelkayaks.eu/games" rel="noopener noreferrer"&gt;Rebel Kayaks&lt;/a&gt; and &lt;a href="https://theoutdoorhub.eu/games" rel="noopener noreferrer"&gt;The Outdoor Hub&lt;/a&gt; too. Problem.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is about sharing one piece of code between several websites, and the quiet way that goes wrong: copies that stop following the original. Run more than one site from one codebase, and you have this problem whether you've noticed it or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why there are copies at all
&lt;/h2&gt;

&lt;p&gt;Each site is its own app, deployed on its own. A shared package works for components, but not for pages: the framework only finds a page inside the app itself. So every site carries a copy of the game. One source in the shared core, and a sync tool writes identical copies.&lt;/p&gt;

&lt;h2&gt;
  
  
  The copy that stops listening
&lt;/h2&gt;

&lt;p&gt;It has bitten before. For a long time the sync tool skipped any file that already existed in a site, so a copy froze at its first sync and never heard about a fix again. Since a few days ago it remembers a fingerprint of what it last wrote. A copy nobody touched gets updated. A copy somebody edited is treated as a deliberate local change, and left alone.&lt;/p&gt;

&lt;p&gt;That second rule is correct, and it is also the trap. Fix a bug in one site's copy, and you haven't fixed the game. You've forked it, silently, and the next fix to the source will never reach that site. Nothing warns you. The site just slowly gets worse than its siblings.&lt;/p&gt;

&lt;h2&gt;
  
  
  A look that travels with the game
&lt;/h2&gt;

&lt;p&gt;My call: Chalk Up! keeps its own look everywhere, Steffo and all, and only the page around it belongs to each site. So the game got its own palette (same colours, its own names), its own buttons and its own fonts, under family names no site would ever use. A punk kayak site and a calm outdoor site can't bleed into it.&lt;/p&gt;

&lt;p&gt;Moving it was supposed to change nothing on its home site, so we checked by machine: screenshots before and after, compared pixel by pixel. 46 pixels out of 941,600 differed, all animations caught mid-frame.&lt;/p&gt;

&lt;h2&gt;
  
  
  What sync doesn't do
&lt;/h2&gt;

&lt;p&gt;Sync handles code. Some parts of a game aren't code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The sounds and fonts&lt;/strong&gt; sit in each site's public folder, and nothing syncs those. Change a sound and you copy it by hand to every site that has the game.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Each site's switch&lt;/strong&gt; for the game, and the card on its games page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The portfolio.&lt;/strong&gt; idunworks.com now has a &lt;a href="https://idunworks.com/games" rel="noopener noreferrer"&gt;games page&lt;/a&gt; that shows every game and links to where it's played. Add or move a game and that card needs updating too.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And sometimes the change goes the other way. RUGD dropped its games entirely that same evening, so I deleted its copies and the sync was told never to bring them back. Otherwise the next sync would have quietly restored them.&lt;/p&gt;

&lt;h2&gt;
  
  
  From notes to a tripwire
&lt;/h2&gt;

&lt;p&gt;When it was done, the question was simple.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So is the game one codebase, more or less?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;More or less, yes. One source, three identical copies, and a short list of things done by hand. We wrote the list down as a note the AI reads when it seems relevant. But does the note get read every time a game changes? Honestly, no: a note is read when a session decides it matters, and the mistakes happen when nobody thinks it matters.&lt;/p&gt;

&lt;p&gt;So we added a hook: a small script that runs every time a file is edited, and stays silent unless the file belongs to a game. Then it says one of three things, depending on what was touched:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nv"&gt;$kind&lt;/span&gt; &lt;span class="k"&gt;in
&lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;msg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Shared game source edited: sync it to every site afterwards."&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
copy&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="nv"&gt;msg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"This is a site's COPY. Edit the source instead: an edited copy stops getting updates."&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
static&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;msg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Sounds and fonts aren't synced. Copy this file to every site with the game."&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first time in a session it also hands over the whole checklist; after that, one line. It talks on two channels: the full text goes to the AI, so the next step already knows, and a short line with a 🎮 shows up for me. A site's own games page stays silent, because that file really does belong to the site.&lt;/p&gt;

&lt;p&gt;We tested it on a real one-line edit to a game file. There was the checklist.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, and how else it could be done
&lt;/h2&gt;

&lt;p&gt;Edited copies stop updating: one source, synced copies, and a warning the moment someone edits a copy. Assets aren't synced: the hook says so. A shared game could take on its host's look: it carries its own palette and fonts now.&lt;/p&gt;

&lt;p&gt;Other ways to do it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One app serving every site.&lt;/strong&gt; No copies at all, but one deploy for everything, and one bad release takes down every site at once. We deploy one site at a time on purpose. Also, it is fun to design variants in look and feel. Because I can. This would probably not scale to high-traffic but it's easy to redo should the need arise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A check that blocks the build&lt;/strong&gt; when a copy differs from its source. Stricter than a reminder, and probably where this ends up. The reminder comes first because it costs nothing and catches the mistake while it's being made, not in a failed deploy an hour later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Syncing the static files too.&lt;/strong&gt; That would close the last hand-copied gap, at the price of one more thing that can overwrite a site's own picture.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you share code between sites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep exactly one place where a change is allowed to start.&lt;/li&gt;
&lt;li&gt;Make the copies know whether they've been touched.&lt;/li&gt;
&lt;li&gt;Write down what isn't synced, and then don't trust the note: put the reminder where the edit happens.&lt;/li&gt;
&lt;li&gt;Prove a move changed nothing, by machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Five boulders a day, now on three sites: &lt;a href="https://vastervikbouldering.com/games/chalk-up" rel="noopener noreferrer"&gt;chalk up&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/one-game-many-sites" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>cms</category>
    </item>
    <item>
      <title>The kayak designer learned to sell t-shirts</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Sat, 07 Nov 2026 19:11:39 +0000</pubDate>
      <link>https://dev.to/tdude/the-kayak-designer-learned-to-sell-t-shirts-nhp</link>
      <guid>https://dev.to/tdude/the-kayak-designer-learned-to-sell-t-shirts-nhp</guid>
      <description>&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; A tool I built for designing kayak colors grew into a t-shirt designer, the T-lab, on five of my sites. They all sell through one shop now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why.&lt;/strong&gt; Run several sites on one codebase and sooner or later something has two truths. This is how I got back to one.&lt;/p&gt;

&lt;h2&gt;
  
  
  A kayak with sleeves
&lt;/h2&gt;

&lt;p&gt;Rebel Kayaks has a page where you paint, or design as it were, a kayak in proper RAL colours for factory coating. Then it occurred to me that a t-shirt is just a kayak with sleeves.&lt;/p&gt;

&lt;p&gt;A few sessions later the T-lab existed. You draw on a tee, pick a colour, pay at rugd.se, and a print shop prints it and posts it. I ordered one and it arrived, the right way up. As of this week it's also the only one ever ordered, which turned out to be excellent timing for tearing the plumbing apart. Because of course I didn't market it and of course I forgot to create a link for it on the site! Doing it now. Oh well :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Five sites, five opinions
&lt;/h2&gt;

&lt;p&gt;My opening message to the AI:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"the setup and infra sucks. It is way too complicated for any tenant admin, except me, with your help, to set up."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Every site kept its own copy of the garment list, and every copy aged in its own way. Somebody forgot...maybe the rubber duck? One site was proudly offering a sports tee the shop no longer sold. You could design it lovingly and then not buy it. How does this happen, I hear you think? Ah, a quick idea, no particular plan for scaling. You know, make a POC and see if it flies. or in code lingo: &lt;em&gt;move fast and break things&lt;/em&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The rugd shop can be an active "gate" but there can only be one truth."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The least trash wins
&lt;/h2&gt;

&lt;p&gt;The AI came back with three ways out. One T-lab for everyone, every site reading the shop live, or keeping the copies and syncing them harder. I asked for the one that "leaves the least trash in code".&lt;/p&gt;

&lt;p&gt;So the shop now says out loud what it sells, and every site listens. When the shop drops a garment, it vanishes everywhere at once. A site keeps only its own taste: which garments to offer, which colours to hide. A festival site can sell one tee. A shop site can sell all of them.&lt;br&gt;
Why this complicated, you think? Glad you asked! It is the exact same layout as a franchise. Now you suddenly know why it's worth it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The robot took the boring jobs
&lt;/h2&gt;

&lt;p&gt;Prices follow what printing really costs, plus a margin. Every night the shop checks its garments against the print shop and tidies up what changed. A cheeky 90% discount code now stops at what the shirt costs to make, instead of you paying people to wear your designs.&lt;/p&gt;

&lt;p&gt;It wasn't flawless. The nightly check did its job perfectly on the first night and told nobody, so for a morning I thought it had never run. Now it announces itself, like a cat that wants credit.&lt;/p&gt;

&lt;p&gt;Then it shipped, one site at a time, because shipping everything at once has bitten me before. The old way of syncing went in the bin, and deleting things is my favourite kind of progress.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, and how else it could be done
&lt;/h2&gt;

&lt;p&gt;Five sites each kept a copy of the truth. Now one shop holds it and the sites read it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Way&lt;/th&gt;
&lt;th&gt;Better at&lt;/th&gt;
&lt;th&gt;Costs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;One T-lab for every site&lt;/td&gt;
&lt;td&gt;Literally one copy&lt;/td&gt;
&lt;td&gt;Every site loses its own look&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The shop pushes changes to each site&lt;/td&gt;
&lt;td&gt;Instant&lt;/td&gt;
&lt;td&gt;The shop has to know every site and chase the ones that are down&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copies, synced now and then (what I had)&lt;/td&gt;
&lt;td&gt;Works with the shop offline&lt;/td&gt;
&lt;td&gt;Two truths, and steps that get forgotten&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sites read the shop (chosen)&lt;/td&gt;
&lt;td&gt;One truth, simple sites&lt;/td&gt;
&lt;td&gt;Each site leans on the shop; a cached copy covers short outages&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The rule I'm keeping: if two places can disagree, they will. Make one of them a reader.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/the-kayak-designer-learned-to-sell-t-shirts" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cms</category>
      <category>aiassisteddev</category>
    </item>
    <item>
      <title>The blog wall that hummed at 50 Hz</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Fri, 06 Nov 2026 11:10:02 +0000</pubDate>
      <link>https://dev.to/tdude/the-blog-wall-that-hummed-at-50-hz-3ofp</link>
      <guid>https://dev.to/tdude/the-blog-wall-that-hummed-at-50-hz-3ofp</guid>
      <description>&lt;p&gt;&lt;em&gt;Much like my past life as a sound engineer, my current work is a delicate mix of UX, design, and code. And just like accidentally creating a 50Hz ground loop hum with 10kW of bass behind it, mixing these three up usually results in a very loud, very public, less enjoyable UX.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The blog on &lt;a href="https://idunworks.com/blog" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt; used to be a tidy grid of cards. Same size, same corners, same polite little "Read more". It looked like every other blog. So I wrote the brief for its replacement in one line:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"There should be NO sweet cards, only splashy brutalist, uneven ones, served at a random pace."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is the story of that sentence, two follow-ups, and the night the wall started to vibrate. It's about what happens when design tasks pile up on top of code that has to measure things, and the one rule that would have saved us an evening.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task one: no sweet cards
&lt;/h2&gt;

&lt;p&gt;The first version came out nicely rude. Cards in different sizes, tilted a few degrees this way and that, loud colours, heavy type. Even the link got bored of saying the same thing: "Read more" became ten different labels, from "Dive in" to "Feed your brain" to "Click for mo'" to "Down the rabbit hole". It is not for every corporate eye with a stick up their ass. It is me. Oh is your ass "profanity"? I must have misunderstood something.&lt;/p&gt;

&lt;p&gt;"Random" needed a small cheat. If the page picks a card's look by rolling dice, the &lt;em&gt;server&lt;/em&gt; rolls one number and the &lt;em&gt;browser&lt;/em&gt; rolls another. The page then redraws itself the moment it loads. So every card's look is worked out from the post's own address. It looks random to you and stays identical for the server and the browser. Random enough, and repeatable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task two: break the grid
&lt;/h2&gt;

&lt;p&gt;Uneven cards in a grid leave holes. A short card next to a tall one leaves a gap under the short one, and the wall looks like a mouth missing teeth. So a small script started packing the cards: measure each one, give it exactly the height it needs, and let later cards slide up into the gaps.&lt;/p&gt;

&lt;p&gt;Then I looked at it again. It still wasn't what I wanted.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I need to have a negative margin left/right for some cards, so they stick out of their parent sideways."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So cards in the outer columns got permission to hang over the edge of the wall. To do that, the script has to know which cards ended up on an edge, and it can only know that after it has packed them.&lt;/p&gt;

&lt;p&gt;And then, of course, even more offset where there is room, in big screens. So a design is not just a design but needs to be checked, rechecked, recoded, repeated for all screens. 20 years ago, we had problems with different browsers interpreting CSS differently. We still have the same problem but from screens having different sizes and resolutions.&lt;/p&gt;

&lt;p&gt;It is like the famous 3 times winner of Tour de France, Greg LeMond said: "It never gets easier, you just go faster".&lt;/p&gt;

&lt;p&gt;More overhang on wide screens. Kept clear of the window edge, so nothing leaks off the page. Fine. Shipped. It looked great.&lt;/p&gt;

&lt;h2&gt;
  
  
  The night it vibrated
&lt;/h2&gt;

&lt;p&gt;A couple of weeks later, after an unrelated deploy, the blog cards started flickering. "Probably 50hz", by my estimate. We opened the page and saw nothing. A tidy, uneven, perfectly still wall.&lt;/p&gt;

&lt;p&gt;The catch, which took longer to find than it should have: "now scroll, I got it after scrolling."&lt;/p&gt;

&lt;p&gt;The wall loads lazily. You get one screenful, and more cards arrive as you scroll. The first screen was fine. It was the cards that came later that started fighting.&lt;/p&gt;

&lt;p&gt;Here's the fight in one card's view of it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I'm in the last column, so I'm an edge card. I get to stick out. I get wider.&lt;/li&gt;
&lt;li&gt;Wider means my text wraps differently. I get shorter.&lt;/li&gt;
&lt;li&gt;Shorter means the packing changes. Now I fit somewhere else, one column in.&lt;/li&gt;
&lt;li&gt;I'm not on the edge any more, so I don't get to stick out. I get narrower.&lt;/li&gt;
&lt;li&gt;Narrower means taller. Taller means I'm back in the last column. Go to 1.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every step was correct. Every rule did exactly what it was told. Together they made a loop, and the browser ran it every frame. When we counted, a card on the live site changed its mind about 700 times a second. That's not a flicker, that's a hum. And you can hear the hiss of your computer's fans revving up like they're partying. Ouch.&lt;/p&gt;

&lt;p&gt;Quick checks never caught it, because quick checks look at the first screen. Nobody scrolls in a quick check. That is what testers are for: they do the stuff a dev would never do because for a dev, when the logic is sound, leave it. Testers' job is to try to break that logic. Kudos to you!&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: you get two changes of heart
&lt;/h2&gt;

&lt;p&gt;The fix is almost embarrassingly small. Each card may change its "I'm on the edge" status twice. After that it keeps whatever it has. The count only starts over when something real happens from outside: the window changes width, or new cards load.&lt;/p&gt;

&lt;p&gt;We tested it the honest way. With the limit, the count dropped to zero. Then we took the limit out again just to be sure, and the hum came straight back. Put it back. Zero. It has been still ever since, on the live site too.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, and how else it could be done
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt; a layout rule (stick out if you're on the edge) changed the very thing it depended on (where you are), so the script and the cards argued forever. &lt;strong&gt;The fix:&lt;/strong&gt; a limit on how often a card may change sides, reset only by outside events.&lt;/p&gt;

&lt;p&gt;There are other ways out, and they trade differently:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ours, the limit:&lt;/strong&gt; a few lines, no design change. The cost is that once in a while a card may keep an overhang it no longer strictly deserves. Nobody will ever notice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shift the card instead of widening it.&lt;/strong&gt; If the overhang only moves the card sideways, without making it wider, the text never rewraps and the loop can't start. The cost: the card pulls away from its neighbour on the inner side, so the wall gets gaps where it should touch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure once, then stop measuring.&lt;/strong&gt; Pack the wall, decide the edges, apply the overhang and don't look again until the window changes. No loop by design. The cost: a card that grows from its overhang can now bump into the card below, so you need extra spacing to be safe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Let the browser do it.&lt;/strong&gt; Native masonry layouts in CSS are on their way, and then there's no script at all to argue with. The cost: not every browser has them yet, so for now you still need the script as a backup.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rule of thumb I'm keeping: &lt;strong&gt;any code that measures something and then changes what it measured is a loop, whether you meant it or not. Give it a way to stop.&lt;/strong&gt; And when you test a page that loads more as you scroll, scroll.&lt;/p&gt;

&lt;p&gt;Each design task was small. "Uneven." "Stick out." "A bit more where there's room." The code said yes to every one. That's the risk: it never tells you which yes was one too many.&lt;/p&gt;

&lt;p&gt;The wall is on &lt;a href="https://idunworks.com/blog" rel="noopener noreferrer"&gt;idunworks.com/blog&lt;/a&gt;. Scroll all the way down. It holds still now. Promise!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/the-blog-wall-that-hummed-at-50-hz" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ux</category>
      <category>cms</category>
    </item>
    <item>
      <title>My sites were writing notes nobody read</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Fri, 06 Nov 2026 11:06:00 +0000</pubDate>
      <link>https://dev.to/tdude/my-sites-were-writing-notes-nobody-read-52h8</link>
      <guid>https://dev.to/tdude/my-sites-were-writing-notes-nobody-read-52h8</guid>
      <description>&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; I asked my AI to build Sentinel, a small tool that reads my whole codebase and tells me where it's unsafe, copied or too clever. Security comes first: risky patterns, routes nobody guards, HTML that goes onto a page unchecked. On the first day it found six websites lovingly maintaining files that no code ever reads. It also found a bug that wasn't one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why.&lt;/strong&gt; If you run several sites from one template, your copies drift. The question is whether you find out from a tool or from a customer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The brief
&lt;/h2&gt;

&lt;p&gt;My words, typos and all: &lt;em&gt;"I want you to make a Sentinel, a lightweight code quality tool, which checks the current architecture, looks for where code is multilied and what could be made simpler."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Before writing a line, the AI checked what already exists. Claude Code's own review commands only look at a diff, so they never see what's already in the tree. jscpd finds copies, Semgrep finds risky patterns and knip finds dead code, but none of them knows my rules. One of those rules is that the logged-in user carries a list of roles, never a single role. So Sentinel became one zero-dependency Node script that knows the house rules, finishes in about two seconds, and keeps a baseline file where every accepted finding needs a written reason.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bark one: the wrong burglar
&lt;/h2&gt;

&lt;p&gt;The first report flagged a "real authorization bug": an admin page checking &lt;code&gt;user.role&lt;/code&gt;, which on my sessions is always undefined. It sounded very serious. It was wrong. That &lt;code&gt;user&lt;/code&gt; came from a different API, which really does return a single &lt;code&gt;role&lt;/code&gt;. The AI traced it, apologised, and narrowed the rule so it only fires on the session user.&lt;/p&gt;

&lt;p&gt;The same report announced 152 "stale" template copies. That was wrong too. The sync manifest lists every template file, including the ones a site changed on purpose, so it can't tell a forgotten copy from a deliberate one. Git history can. The real count was 27.&lt;/p&gt;

&lt;p&gt;A watchdog that barks at the postman is worse than no dog, so both got fixed before anything else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bark two: the drawer
&lt;/h2&gt;

&lt;p&gt;The 27 were real. The script that copies shared files into each site skipped any file that already existed, forever. Fix a template and the fix stopped at the first site that had ever synced. A better login error message had been in the template for a while and had reached one site out of six.&lt;/p&gt;

&lt;p&gt;Now the sync remembers a hash of what it last wrote. If a site's copy still matches that hash, nobody touched it, so sync updates it. If the hash differs, it's the site's own version and it's left alone. The first real run carried a fix to all six sites with no &lt;code&gt;--force&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then the drawer. Every site had its own folder of translation files, about 350 of them across the six. Nothing imported them. The sites read their texts from the shared package, so the copies were decoration. Someone had still been editing them faithfully. One site said &lt;em&gt;"We're out kayaking right now. Please come back a bit later."&lt;/em&gt; Another said they were out playing guitar. Nobody ever saw either, because the page that should show them displayed the raw key &lt;code&gt;home.fallback_title&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;The folder is gone. The missing texts moved to the one place that's actually read, and Sentinel now checks every translation key the code asks for. It found 25 more that pointed to the wrong place, plus a T-lab label defined twice in the same object, where the second silently wins. The size readout lost its percentage that way.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, and how else to do it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Copies froze at first sync.&lt;/strong&gt; Fixed: sync records hashes and updates untouched copies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dead translation folders, edited by hand.&lt;/strong&gt; Deleted, and the live texts recovered.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missing and misrouted translation keys.&lt;/strong&gt; Fixed, and now a check.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two false alarms on day one.&lt;/strong&gt; Rules narrowed, with tests for both.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The security findings.&lt;/strong&gt; Checked one by one, and the real ones fixed. I'll spare you the details.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Better at&lt;/th&gt;
&lt;th&gt;Costs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Claude's diff review commands&lt;/td&gt;
&lt;td&gt;Catching problems in each change&lt;/td&gt;
&lt;td&gt;Blind to everything already merged&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;jscpd + Semgrep + knip&lt;/td&gt;
&lt;td&gt;Mature, precise, big rule libraries&lt;/td&gt;
&lt;td&gt;Three configs, no idea of your house rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A home-made Sentinel&lt;/td&gt;
&lt;td&gt;Knows your rules, records decisions&lt;/td&gt;
&lt;td&gt;You maintain it, and it starts out wrong&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Rule of thumb: if a file is copied, something must own updating it. If nothing does, you've built a drawer.&lt;/p&gt;

&lt;p&gt;Rebel Kayaks, one of the six, is at &lt;a href="https://rebelkayaks.eu" rel="noopener noreferrer"&gt;rebelkayaks.eu&lt;/a&gt;. After its next deploy, its fallback page says something human.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/my-sites-were-writing-notes-nobody-read" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>aiassisteddev</category>
    </item>
    <item>
      <title>Most of my robots were me</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Sun, 01 Nov 2026 23:00:00 +0000</pubDate>
      <link>https://dev.to/tdude/most-of-my-robots-were-me-fen</link>
      <guid>https://dev.to/tdude/most-of-my-robots-were-me-fen</guid>
      <description>&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; I added a counter to my own analytics to find out how&lt;br&gt;
many robots visit my sites, and whether any of them would say who they were.&lt;br&gt;
Nearly every number it gave me was measuring something other than what I&lt;br&gt;
thought.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why.&lt;/strong&gt; Because a number you have not grouped by anything is not yet&lt;br&gt;
information. There is a difference between belief and knowing.&lt;/p&gt;

&lt;h2&gt;
  
  
  5 reads, 62 bots
&lt;/h2&gt;

&lt;p&gt;The counter went live, I posted a new piece on LinkedIn and Facebook, and came&lt;br&gt;
back to "5 reads, 62 bots" a few minutes later. Sixty-two robots on one post&lt;br&gt;
felt like arrival.&lt;/p&gt;

&lt;p&gt;It was not. The single biggest source was Facebook, fetching the page over and&lt;br&gt;
over from different addresses to build one preview card. LinkedIn did it twice&lt;br&gt;
more. &lt;strong&gt;Sharing a link looks almost exactly like being crawled&lt;/strong&gt;, and nothing on&lt;br&gt;
my dashboard said so.&lt;/p&gt;

&lt;p&gt;The actual AI crawlers had sent one request each. GPTBot, ClaudeBot,&lt;br&gt;
PerplexityBot and Common Crawl had each knocked once and left. That is&lt;br&gt;
discovery, not reading.&lt;/p&gt;

&lt;p&gt;So the headline split in two: AI crawlers in one box, link previews in another.&lt;br&gt;
By the end of the day Facebook had fetched that single page from &lt;strong&gt;130 different&lt;br&gt;
addresses&lt;/strong&gt;, every one of them provably Facebook. I had assumed a preview card&lt;br&gt;
was one request.&lt;/p&gt;

&lt;h2&gt;
  
  
  21,791 visits, and 20,610 of them were me
&lt;/h2&gt;

&lt;p&gt;The next morning the counter said 21,791.&lt;/p&gt;

&lt;p&gt;I was briefly delighted. Then I grouped it, and found 20,709 visits from a&lt;br&gt;
client calling itself &lt;code&gt;curl&lt;/code&gt;, hitting the homepage, from three addresses, none&lt;br&gt;
of which had an address at all.&lt;/p&gt;

&lt;p&gt;Every one of my app containers has a health check. It runs &lt;code&gt;curl&lt;/code&gt; against its&lt;br&gt;
own homepage every fifteen seconds to decide whether the container is still&lt;br&gt;
alive. Seven containers, four probes a minute each, is about forty thousand&lt;br&gt;
requests a day. My bot filter is deliberately broad, it matches the word&lt;br&gt;
&lt;code&gt;curl&lt;/code&gt;, and so every single heartbeat was filed as an automated visitor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ninety-five percent of my bot traffic was my own server taking its own&lt;br&gt;
pulse.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The fix is one line. Working out which signal to trust took the rest of the&lt;br&gt;
morning. Not the user-agent, because anything can claim to be anything. Not the&lt;br&gt;
path, because real crawlers ask for the homepage too. The health check is&lt;br&gt;
distinguishable because it talks to the app directly and never passes through&lt;br&gt;
the web server in front, so it arrives with &lt;strong&gt;no client address at all&lt;/strong&gt;. No&lt;br&gt;
address means it came from inside the house.&lt;/p&gt;

&lt;p&gt;This can break, and I would rather it broke this way round. If the proxy ever&lt;br&gt;
stopped handing me the real client address, I would quietly undercount real&lt;br&gt;
robots instead of confidently counting imaginary ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deleting them mattered more than I expected
&lt;/h2&gt;

&lt;p&gt;Fixing the code only stops the bleeding, so I deleted the 20,787 heartbeats&lt;br&gt;
already recorded.&lt;/p&gt;

&lt;p&gt;That sounds like tidying. It was not. The counts are also rolled up into a small&lt;br&gt;
permanent table, so that this October stays comparable with next October: the&lt;br&gt;
raw records are deliberately short-lived, the daily totals are not. Cleaning&lt;br&gt;
only the raw table would have left today's summary looking healthy while the&lt;br&gt;
permanent history went on insisting I had twenty thousand robot visitors on the&lt;br&gt;
day I shipped the counter. Wrong numbers that expire are a nuisance. Wrong&lt;br&gt;
numbers kept forever are a liability.&lt;/p&gt;

&lt;p&gt;I nearly made it worse. My first instinct was to delete everything with no&lt;br&gt;
client address, which is the obvious signature. Checking the query before&lt;br&gt;
running it showed that would also have deleted perfectly good records for&lt;br&gt;
Googlebot, Bingbot and ClaudeBot, recorded before I started keeping origins at&lt;br&gt;
all. The predicate had to be narrower.&lt;/p&gt;

&lt;p&gt;Pruned on both sides, the real figure for that first day is &lt;strong&gt;914 visits from 26&lt;br&gt;
bot families&lt;/strong&gt;: far less impressive, and the first one I believe.&lt;/p&gt;

&lt;h2&gt;
  
  
  I was wrong about asking them who they are
&lt;/h2&gt;

&lt;p&gt;The thing I actually wanted was an email address. If a robot is reading&lt;br&gt;
everything I write, I would quite like to know who to talk to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I do NOT track human users like this. Please read on!&lt;/p&gt;

&lt;p&gt;I assumed this was hopeless. There is a header in the HTTP spec, &lt;code&gt;From:&lt;/code&gt;, meant&lt;br&gt;
to carry the email address of whoever is responsible for an automated client,&lt;br&gt;
and my firm expectation was that nobody had used it since about 1996. I said so&lt;br&gt;
out loud, more than once, and logged it mostly as a joke.&lt;/p&gt;

&lt;p&gt;Once the heartbeats were out of the way, 66 visits had filled it in.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;googlebot(at)googlebot.com&lt;br&gt;
bingbot(at)microsoft.com&lt;br&gt;
gptbot(at)openai.com&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Google, Microsoft and OpenAI all announce themselves, unprompted, in a header I&lt;br&gt;
had written off. Two smaller crawlers I did not recognise went further and gave&lt;br&gt;
real abuse-contact addresses. The obfuscated "(at)" is their own, presumably so&lt;br&gt;
the addresses survive being scraped out of server logs by somebody else's robot,&lt;br&gt;
which is a pleasing piece of symmetry.&lt;/p&gt;

&lt;p&gt;So the answer to "can I ask a robot who runs it" turns out to be: mostly you do&lt;br&gt;
not have to ask. The well-behaved ones have been telling me all along and I was&lt;br&gt;
not reading it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, and what else I could have done
&lt;/h2&gt;

&lt;p&gt;Three numbers were wrong in three different ways. The first counted link&lt;br&gt;
previews as readers. The second counted my own health checks as visitors. The&lt;br&gt;
third, the one I never even displayed, was sitting there full of answers because&lt;br&gt;
I had assumed it would be empty.&lt;/p&gt;

&lt;p&gt;The fix for the big one was a single condition, and the alternatives were all&lt;br&gt;
worse:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Instead of "no client address"&lt;/th&gt;
&lt;th&gt;I would gain&lt;/th&gt;
&lt;th&gt;It would cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Matching the user-agent&lt;/td&gt;
&lt;td&gt;Obvious and readable&lt;/td&gt;
&lt;td&gt;Anything can claim to be &lt;code&gt;curl&lt;/code&gt;, and real tools legitimately are&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Matching the homepage path&lt;/td&gt;
&lt;td&gt;Also obvious&lt;/td&gt;
&lt;td&gt;Real crawlers request the homepage constantly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Excluding the container's own network range&lt;/td&gt;
&lt;td&gt;Precise today&lt;/td&gt;
&lt;td&gt;Breaks the first time the network layout changes, silently&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Not counting bots at all&lt;/td&gt;
&lt;td&gt;No wrong numbers&lt;/td&gt;
&lt;td&gt;No numbers&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I went hunting for robots and found a mirror. Before you trust a number, make it&lt;br&gt;
sit still and tell you what it is made of. Mine was 95 percent heartbeat.&lt;/p&gt;

&lt;p&gt;Now comes the hard question: are you sure your (third party) tracker is made up&lt;br&gt;
of the same suspicios minds? Are you sure they filter out the noise or do they&lt;br&gt;
sell you snake oil? &lt;a href="https://idunworks.com/forms/give-us-a-shout" rel="noopener noreferrer"&gt;Give us a shout&lt;/a&gt; and we can check&lt;br&gt;
for you!&lt;/p&gt;

&lt;p&gt;Next in this series: the most requested page on my server, which is a page that&lt;br&gt;
does not exist, and what I did to the robots asking for it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/blog/most-of-my-robots-were-me" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>bots</category>
    </item>
    <item>
      <title>Three holes in a green CI, and a lock for the free plan</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Fri, 30 Oct 2026 09:55:37 +0000</pubDate>
      <link>https://dev.to/tdude/three-holes-in-a-green-ci-and-a-lock-for-the-free-plan-4ak0</link>
      <guid>https://dev.to/tdude/three-holes-in-a-green-ci-and-a-lock-for-the-free-plan-4ak0</guid>
      <description>&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; On a site we worked on recently, the test pipeline went green across the board, and we looked into what green actually covered. Three things turned out not to be covered at all. This is how we found and closed each one, on a free GitHub plan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why.&lt;/strong&gt; A green CI tells you that the tests it ran passed. It doesn't tell you which tests it didn't run, or whether anything waits for it before you deploy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The question
&lt;/h2&gt;

&lt;p&gt;Once CI was green, we wrote the next step down as one line:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;go on with test, CI and safety planning. Output a shortlist in order of priority&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That gave us ten items, and the top two were about the pipeline itself, not about the code. So we started at the top.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hole 1: tests that CI never ran
&lt;/h2&gt;

&lt;p&gt;The backend is a handful of small services, and CI runs each one's tests in its own job. A couple of services had plenty of tests and no job at all. Nobody had removed them; they had just never been added to the list.&lt;/p&gt;

&lt;p&gt;Adding them was one word each in the workflow file. Then the first run showed what they had been hiding:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A pile of tests errored instead of running.&lt;/strong&gt; Their database tests looked for a Postgres address in a dedicated variable. One test file skipped politely when it wasn't set; the files that borrowed its fixtures didn't, and crashed on an empty URL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The async tests failed&lt;/strong&gt; because &lt;code&gt;pytest-asyncio&lt;/code&gt; wasn't installed in CI. They were never broken; they were never run.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The fix was a small &lt;code&gt;conftest.py&lt;/code&gt; with one rule: &lt;strong&gt;without a test database, skip every test that needs one. In CI, fail instead.&lt;/strong&gt; The second half matters most. A broken database in CI should turn the run red, not quietly turn the database tests into skips.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;pytest_configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;_db_ready&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TEST_DB_ENV&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;_db_ready&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;_database_reachable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;_db_ready&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CI&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;true&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="n"&gt;pytest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;UsageError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CI: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;TEST_DB_ENV&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; unreachable at &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;_redact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;_redact&lt;/code&gt; drops the password from the URL before it reaches a log, because CI logs are read by more people than your secrets file is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hole 2: tests that built a different schema than production
&lt;/h2&gt;

&lt;p&gt;In production, the service builds its tables by running its migrations when the container starts. Its tests built them straight from the models with &lt;code&gt;create_all&lt;/code&gt;. Two roads to the same place, as long as nobody forgets a migration. Forget one, and the tests pass while production queries fail.&lt;/p&gt;

&lt;p&gt;So we added one test: run the real migrations on an empty database, then ask Alembic to compare the result with the models.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;compare_metadata&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;models and migrations differ:&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It found drift on its first run. Harmless drift, and the database itself needed no change. Still, a test that checks for drift and finds some on day one has earned its place.&lt;/p&gt;

&lt;p&gt;Another service had the opposite problem. Its background jobs opened their own database connection from the real connection string, not the test one. In CI that pointed at an empty database, so the jobs failed, logged an error and moved on, and the tests passed. A few tests had in fact been passing &lt;em&gt;because&lt;/em&gt; a background job failed silently. Now the jobs use the test database, or stay off unless a test asks for them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hole 3: nothing waited for green
&lt;/h2&gt;

&lt;p&gt;The repo is private and on a free plan, and GitHub's branch protection, the thing that stops a red commit from merging, needs a paid plan there. So a commit could go red in CI and still be deployed a minute later.&lt;/p&gt;

&lt;p&gt;Every deploy goes through one command, so the lock went there. Before anything is synced or deployed, a small script:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;checks that the commit being deployed is the one on the main branch,&lt;/li&gt;
&lt;li&gt;finds the CI run for that commit, and waits for it if it's still going,&lt;/li&gt;
&lt;li&gt;refuses unless it ended in success.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Docs-only commits don't trigger CI at all, so those get special handling: if every file changed since the last tested commit is documentation, that earlier run counts. Anything else without a run of its own is refused.&lt;/p&gt;

&lt;p&gt;There's an escape hatch, &lt;code&gt;ALLOW_UNTESTED=1&lt;/code&gt;, which prints a warning and goes ahead. It's for emergencies, not for when CI is slow.&lt;/p&gt;

&lt;p&gt;We tested the script against a fake GitHub CLI in a throwaway repo, one case at a time: green, red, cancelled, still running, docs-only, untested code, not pushed, and the override. Then against the real thing, right after a push:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;… waiting for Test Suite run on &amp;lt;commit&amp;gt;
✓ CI green on &amp;lt;commit&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same change fixed the order of pushes in the deploy command, too. It pushed the main repo before the submodule it points to, which is exactly the wrong way round.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, how we fixed it, and how else it could be done
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Services missing from CI:&lt;/strong&gt; added to the job list, plus the one test dependency they needed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database tests that errored or skipped:&lt;/strong&gt; a shared rule that skips without a database and fails in CI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Schema built two ways:&lt;/strong&gt; one test that runs the real migrations and compares them with the models.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background jobs leaking out of the test database:&lt;/strong&gt; pointed at the test database, or switched off by default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Red commits deployable:&lt;/strong&gt; a CI check inside the deploy command, with a loud override.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other ways to make deploys wait for CI:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Better at&lt;/th&gt;
&lt;th&gt;Costs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;A check in the deploy command&lt;/strong&gt; (what we did)&lt;/td&gt;
&lt;td&gt;Free, works on any plan, covers the only way you deploy&lt;/td&gt;
&lt;td&gt;Only protects that one command; a manual deploy can skip it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Branch protection&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Enforced by GitHub for everyone, before merge&lt;/td&gt;
&lt;td&gt;Needs a paid plan for private repos on personal accounts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Deploy from CI&lt;/strong&gt; (CI deploys only after tests pass)&lt;/td&gt;
&lt;td&gt;No way around it, and no laptop involved&lt;/td&gt;
&lt;td&gt;Server credentials live in CI, and you need to trust and maintain that path&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;A pre-push hook&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Catches it before it even leaves your machine&lt;/td&gt;
&lt;td&gt;Runs the tests locally on every push, and is easy to skip&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Before you trust a green CI
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;List your services and compare that with the list CI runs. They drift apart.&lt;/li&gt;
&lt;li&gt;Make "no database" a skip on your laptop and a failure in CI.&lt;/li&gt;
&lt;li&gt;If production migrates and tests use &lt;code&gt;create_all&lt;/code&gt;, add one test that compares the two.&lt;/li&gt;
&lt;li&gt;Grep for anything that opens its own database connection; tests should own all of them.&lt;/li&gt;
&lt;li&gt;Make your deploy ask CI before it does anything, and make skipping that loud.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Green means a bit more there now than it did this morning. More from the workshop is on the &lt;a href="https://idunworks.com/blog" rel="noopener noreferrer"&gt;Ship Log&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>git</category>
      <category>ci</category>
      <category>ai</category>
    </item>
    <item>
      <title>My most popular page does not exist</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Thu, 29 Oct 2026 23:00:00 +0000</pubDate>
      <link>https://dev.to/tdude/my-most-popular-page-does-not-exist-3e8p</link>
      <guid>https://dev.to/tdude/my-most-popular-page-does-not-exist-3e8p</guid>
      <description>&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; While working out why my new robot counter had such a&lt;br&gt;
flattering opinion of my readership, I read the raw server log and found that&lt;br&gt;
the most requested page on the whole machine was one that has never existed.&lt;br&gt;
This is what I did about it, and the mistake that nearly took all my sites&lt;br&gt;
offline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why.&lt;/strong&gt; Building the trap took an afternoon. Working out what must never be&lt;br&gt;
trapped took longer, and that is the part worth writing down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fifteen thousand requests for nothing
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;/wordpress&lt;/code&gt; was the most requested path on the server for my newly deployed&lt;br&gt;
site. More than the homepage. Fifteen thousand requests in a single log file.&lt;/p&gt;

&lt;p&gt;I have never run WordPress there (!). I once had a React front end that read&lt;br&gt;
content from WordPress on a different machine entirely, which is not the same&lt;br&gt;
thing and would not leave this trail.&lt;/p&gt;

&lt;p&gt;Every one of those requests forged a browser user-agent, rotating through&lt;br&gt;
Chrome, Edge, Safari, Firefox and Opera in almost exactly equal numbers. That is&lt;br&gt;
one scanner with a costume box, not many visitors. It is also the kind of sneaky&lt;br&gt;
little robot my shiny new counter cannot see, because it is pretending to be a&lt;br&gt;
person. Once identified, never doubted. No amount of counting fixes that.&lt;/p&gt;

&lt;p&gt;What it can see is that the requests came from a couple of dozen addresses, two&lt;br&gt;
of which accounted for 87 percent of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Twenty bytes a second
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;&lt;em&gt;tarpit&lt;/em&gt;&lt;/strong&gt; is an old idea (a pit and a load of tar): answer, but answer so&lt;br&gt;
irritatingly slow that the other side wastes real time. Ha! So I gave them&lt;br&gt;
something to download. A file called &lt;code&gt;wordpress_backup.sql&lt;/code&gt;, served at &lt;em&gt;twenty&lt;br&gt;
bytes&lt;/em&gt; per second. The whole megabyte takes just over fourteen hours.&lt;/p&gt;

&lt;p&gt;The sketch I started from bolted on a Python service whose entire job was to&lt;br&gt;
dribble ones and zeros forever. The web server does it alone, sulkily, for&lt;br&gt;
nothing: a finite file served slowly enough is indistinguishable from an&lt;br&gt;
infinite one, so there is no extra process, no extra port and nothing extra to&lt;br&gt;
keep patched. I also dropped a (for me) clever header containing a JavaScript&lt;br&gt;
infinite loop, on the grounds that response headers are not executed by&lt;br&gt;
anything.&lt;/p&gt;

&lt;p&gt;Then the web server and I fell out over what "slow" means.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The rate limit throttles the headers too.&lt;/strong&gt; A client spends eighteen seconds&lt;br&gt;
receiving about 360 bytes of response headers, so it is stuck before it even&lt;br&gt;
learns the filename it is being offered. I spent a while convinced my header&lt;br&gt;
configuration was broken, when in fact it was still in flight. Stained by tar up&lt;br&gt;
to my knees already...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The defaults make a worse trap than small buffers do.&lt;/strong&gt; Out of the box the&lt;br&gt;
server hands over one four-kilobyte chunk immediately and then goes quiet for&lt;br&gt;
about three and a half minutes, which any scanner with an inactivity timeout&lt;br&gt;
treats as a dead connection and abandons. Shrinking the buffers turns that into&lt;br&gt;
a steady dribble, so the connection stays interesting enough to sit in. Smaller&lt;br&gt;
buffers, stickier trap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Up to my elbows in tar
&lt;/h2&gt;

&lt;p&gt;Then I widened it to the other things robots ask for. &lt;code&gt;/.env&lt;/code&gt;, &lt;code&gt;/.git/config&lt;/code&gt;,&lt;br&gt;
the files that hand over credentials when they exist. All of those begin with a&lt;br&gt;
dot, so a rule for dot paths looked obvious.&lt;/p&gt;

&lt;p&gt;So does &lt;code&gt;/.well-known/acme-challenge/&lt;/code&gt;, which is how my TLS certificates prove&lt;br&gt;
they are mine when they renew.&lt;/p&gt;

&lt;p&gt;A rule that trapped every dot path would have tarpitted my own certificate&lt;br&gt;
renewals. Nothing would have broken that day, or that week. It would have&lt;br&gt;
surfaced a month or two later as expired certificates on every site at once, and&lt;br&gt;
I would never have connected it to the "clever" thing I did in October.&lt;/p&gt;

&lt;p&gt;There is a second exclusion of the same shape. Search engines speculatively ask&lt;br&gt;
every site for &lt;code&gt;/wp-json/&lt;/code&gt; and &lt;code&gt;/wp-sitemap.xml&lt;/code&gt;, just in case WordPress is&lt;br&gt;
hiding there. A blanket rule for anything starting with &lt;code&gt;wp&lt;/code&gt; would have put&lt;br&gt;
Googlebot in the tarpit for fourteen hours at a time. I first assumed those&lt;br&gt;
requests were leftovers from some old setup and would fade. They are not. They&lt;br&gt;
are standard crawler behaviour and they will keep arriving forever (or until&lt;br&gt;
Mullenweg goes crazy again), so the exclusion is permanent. The note in the&lt;br&gt;
config now says so. The version where it looks temporary is the version somebody&lt;br&gt;
deletes at the Spring cleanout.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it has caught
&lt;/h2&gt;

&lt;p&gt;So far the trap has held 91 requests for a combined &lt;strong&gt;25.6 hours&lt;/strong&gt;. The average&lt;br&gt;
stay is seventeen minutes. Twenty lasted more than ten. The longest single&lt;br&gt;
connection sat there for &lt;strong&gt;eight hours and ten minutes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The funniest part is that it is barely catching WordPress scanners at all. The&lt;br&gt;
top catches are &lt;code&gt;/.env&lt;/code&gt; and &lt;code&gt;/.git/config&lt;/code&gt;. I built a little black sticky goo&lt;br&gt;
for one kind of robot and it filled up with another. Never thought slow&lt;br&gt;
connections could bring me so much joy :)&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, and what else I could have done
&lt;/h2&gt;

&lt;p&gt;A page that does not exist was my most popular page. It now answers, very&lt;br&gt;
slowly, to everyone except the three kinds of visitor that must never be slowed&lt;br&gt;
down: real people, search engines doing their normal speculative sniffing, and&lt;br&gt;
my own certificates renewing themselves.&lt;/p&gt;

&lt;p&gt;A tarpit is not the only answer, and it is not obviously the best one:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Instead of a tarpit&lt;/th&gt;
&lt;th&gt;I would gain&lt;/th&gt;
&lt;th&gt;It would cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Returning "not found"&lt;/td&gt;
&lt;td&gt;Free, no risk at all&lt;/td&gt;
&lt;td&gt;The scanner leaves in two milliseconds and is back tomorrow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Blocking the worst networks at the firewall&lt;/td&gt;
&lt;td&gt;The cheapest real relief; two addresses were most of the traffic&lt;/td&gt;
&lt;td&gt;Those addresses rotate, so it is maintenance forever&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auto-banning after a few probes&lt;/td&gt;
&lt;td&gt;Adapts without a hand-maintained list&lt;/td&gt;
&lt;td&gt;One more moving part, and a false positive blocks a person&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Serving a deliberately huge file at full speed&lt;/td&gt;
&lt;td&gt;Costs them bandwidth immediately&lt;/td&gt;
&lt;td&gt;Costs me the same bandwidth, which is the wrong trade&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The honest caveat is that a tarpit costs me something too. I hold a connection&lt;br&gt;
so that they hold one, and if the scanning came from thousands of addresses&lt;br&gt;
instead of a couple of dozen, that trade would stop favouring me. Hence a hard&lt;br&gt;
ceiling on how many of these connections can exist at once, and a refused one&lt;br&gt;
being closed rather than answered.&lt;/p&gt;

&lt;p&gt;And a small confession about measurement, which is becoming a theme. My first&lt;br&gt;
instinct was to keep these requests out of the logs entirely, since fifteen&lt;br&gt;
thousand lines a day is noise. I did exactly that, and then realised I had built&lt;br&gt;
a trap with no way of telling whether it caught anything. They now go to their&lt;br&gt;
own log file, which is how I know about the eight hours.&lt;/p&gt;

&lt;p&gt;Hit me in the comments if you think my reasoning is flawed, or if you think bots&lt;br&gt;
should be treated as equals.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/blog/my-most-popular-page-does-not-exist" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>bots</category>
    </item>
    <item>
      <title>I locked the door my deploy knocked on</title>
      <dc:creator>Tdude</dc:creator>
      <pubDate>Wed, 28 Oct 2026 10:04:34 +0000</pubDate>
      <link>https://dev.to/tdude/i-locked-the-door-my-deploy-knocked-on-1jm3</link>
      <guid>https://dev.to/tdude/i-locked-the-door-my-deploy-knocked-on-1jm3</guid>
      <description>&lt;p&gt;&lt;strong&gt;What this is about.&lt;/strong&gt; I asked my AI for a full maintenance audit of my CMS, and we spent an afternoon closing what it found. Then the first deploy failed, and one of my own fixes had caused it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why.&lt;/strong&gt; Every fix changes something somebody depends on, and sometimes that somebody is your own tooling. It's better to find out in a rollback than in an outage.&lt;/p&gt;

&lt;h2&gt;
  
  
  The audit
&lt;/h2&gt;

&lt;p&gt;My brief was short:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;i want a full audit with a report at each step.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It came back in parts: UX, marketing, product, and security. I said "let's concentrate on the sec. items first", and we did them in a few rounds. The ones worth telling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The quiz answered itself.&lt;/strong&gt; My course pages fetched each quiz with the right answer included, unscrambled, and the page just didn't show it. Anyone opening the browser's network tab with a beautiful or curious mind could get a perfect score. Students now get the &lt;em&gt;questions&lt;/em&gt;, and only course editors get the &lt;em&gt;answers&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The browser named its own price.&lt;/strong&gt; When you bought a course, the checkout trusted the amount the browser sent. Now the server looks up the price itself, and when the payment comes back it checks that what was paid matches what was owed. If it doesn't, nothing gets unlocked and I get a loud log line. In a webshop this is one of the building blocks. I started the courses out of a need for a small course platform, no payment. Easy to forget the nuances.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A door between my services had a wall, but no lock.&lt;/strong&gt; The route that grants course access after a payment can only be reached from inside my own network. It still trusted anything that reached it. It now wants a shared secret, and it refuses when the secret isn't set, instead of letting everyone in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logging out didn't log you out.&lt;/strong&gt; The button cleared your cookies, but the session behind them stayed valid until it expired. Logout now ends the session on the server too. A deactivated account, or a changed password, ends every session that account has. Easy to miss when you're up to your elbows in code-grease creating a course platform.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each fix came with a test, and the test suites ran green: about 620 tests across three services. I've seen worse.&lt;/p&gt;

&lt;h2&gt;
  
  
  The deploy
&lt;/h2&gt;

&lt;p&gt;Another fix from the same evening hid the API's documentation pages in production. FastAPI publishes them at &lt;code&gt;/docs&lt;/code&gt; by default, a guided tour of every endpoint you have. Strangers don't need that tour.&lt;/p&gt;

&lt;p&gt;The first site went out, and the deploy stopped with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Health checks timed out after 120s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My deploys are of the blue-green kind: The new version starts next to the old one, a script checks that it's healthy, and only then does traffic move over. The script's idea of "healthy" was asking for &lt;code&gt;/docs&lt;/code&gt; and getting a page back. I had just made sure it would never get one again.&lt;/p&gt;

&lt;p&gt;So for two minutes the new version stood there, perfectly fine, knocking on a door I had locked an hour earlier. Then the script gave up, the old version kept serving, and nobody visiting the site noticed a thing.&lt;/p&gt;

&lt;p&gt;The fix was one word in three scripts: ask &lt;code&gt;/health&lt;/code&gt; instead. That route exists precisely to say "I'm alive". Nobody will ever hide it, because hiding it would be pointless. Go there and it will kick your ass to 404.&lt;/p&gt;

&lt;p&gt;Then the evening ran long. Halfway through the fleet I said "hold off the rest for tomorrow", and the AI started stopping a deploy that was already halfway out. Yeah, what does "hold off" mean really? I corrected it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;i meant to not start a new deploy. Finish what is started as agreed&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Fair. A half-finished deploy is worse than either a finished one or one that never started. The last site went out the next morning, and every site passed the same checks: no docs, logout only by POST, internal routes closed to the public, and a quiz with no answers in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened, how we fixed it, and how else it could be done
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quiz answers in the response:&lt;/strong&gt; a separate public schema without the answer field.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client-set prices:&lt;/strong&gt; the server prices the order and checks the paid amount before it unlocks anything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unlocked internal route:&lt;/strong&gt; a shared secret, with the route closed if the secret is missing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logout that didn't:&lt;/strong&gt; sessions are revoked on the server at logout, deactivation and password change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The failed deploy:&lt;/strong&gt; health checks ask a dedicated &lt;code&gt;/health&lt;/code&gt; route, not the docs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other ways to handle the docs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Better at&lt;/th&gt;
&lt;th&gt;Costs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Turn them off in production&lt;/strong&gt; (what we did)&lt;/td&gt;
&lt;td&gt;Nothing to find, nothing to maintain&lt;/td&gt;
&lt;td&gt;You lose the docs in production, so you read them locally&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Keep them behind an admin login&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Docs are still there when you need them live&lt;/td&gt;
&lt;td&gt;Another protected route to get right&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Block them at the web server&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;One rule covers every service&lt;/td&gt;
&lt;td&gt;The app still serves them to anything inside the network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Leave them on&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Easy for integrators&lt;/td&gt;
&lt;td&gt;A free map of your API for anyone who's curious&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Before you lock something
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Search your deploy, monitoring and health scripts for the URL you're closing.&lt;/li&gt;
&lt;li&gt;Give every service a &lt;code&gt;/health&lt;/code&gt; route, and point every probe at it.&lt;/li&gt;
&lt;li&gt;Make sure a failed health check rolls back, before you ever need it to.&lt;/li&gt;
&lt;li&gt;When someone says "stop", ask if "don't start" or "abort" is what they mean. &lt;a href="https://www.youtube.com/watch?v=7lVXT5NZsSM" rel="noopener noreferrer"&gt;Or right&lt;/a&gt;?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The rollback did exactly what I built it for, on the first night it was needed. More from the workshop is on the &lt;a href="https://idunworks.com/blog" rel="noopener noreferrer"&gt;Ship Log&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://idunworks.com/blog/i-locked-the-door-my-deploy-knocked-on" rel="noopener noreferrer"&gt;idunworks.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>devops</category>
      <category>ai</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
