<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Netlify on Deux</title><link>https://deux.top/en/tags/netlify/</link><description>Recent content in Netlify on Deux</description><image><title>Deux</title><url>https://deux.top/branding/og-default.jpg</url><link>https://deux.top/branding/og-default.jpg</link></image><generator>Hugo</generator><language>en-US</language><copyright>2026 二重奏</copyright><lastBuildDate>Thu, 05 Nov 2026 11:34:56 +0000</lastBuildDate><atom:link href="https://deux.top/en/tags/netlify/index.xml" rel="self" type="application/rss+xml"/><item><title>How a Single Comment in a Config File Saved a Production Deployment</title><link>https://deux.top/en/posts/zz-s07/</link><pubDate>Thu, 05 Nov 2026 00:00:00 +0900</pubDate><guid>https://deux.top/en/posts/zz-s07/</guid><description>A typo in the Netlify branch name caused all &amp;#39;Edit this post on GitHub&amp;#39; links to return 404 errors. This post explores why all CI builds and tests passed despite the broken links.</description><content:encoded><![CDATA[<blockquote>
<p>This article was machine-translated by AI and may contain inaccuracies. See the <a href="/zh/posts/zz-s07/">Chinese original</a> for the authoritative version.</p>
</blockquote>
<h2 id="1-all-green-but-the-links-are-dead">1. All green, but the links are dead</h2>
<p>On the third day after launch, I happened to click on <strong>&ldquo;Improve this post on GitHub&rdquo;</strong> at the bottom of an article page, and it led to a 404. I checked two other articles out of curiosity; they were the same.</p>
<p>The strange thing is:</p>
<table>
	<thead>
			<tr>
					<th>Check 查</th>
					<th>Result</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Local <code>hugo --gc --minify</code></td>
					<td>✅</td>
			</tr>
			<tr>
					<td>CI build-check</td>
					<td>✅</td>
			</tr>
			<tr>
					<td>feature-check 26 项</td>
					<td>✅</td>
			</tr>
			<tr>
					<td>Netlify deploy date 志</td>
					<td>✅ All green</td>
			</tr>
			<tr>
					<td>That lin接</td>
					<td><strong>404</strong></td>
			</tr>
	</tbody>
</table>
<blockquote>
<p>All automated checks were verifying &ldquo;whether the page can be generated,&rdquo; but none were verifying &ldquo;whether the generated URL is correct.&rdquo;</p>
</blockquote>
<h2 id="2-a-single-line-of-main">2. A single line of main</h2>
<p>The site-level <code>editPost</code> configuration looks like this (simplified):</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="cl"><span class="p">[</span><span class="nx">params</span><span class="p">.</span><span class="nx">editPost</span><span class="p">]</span>
</span></span><span class="line"><span class="cl">  <span class="nx">URL</span> <span class="p">=</span> <span class="s2">&#34;https://github.com/piscon/myblog/blob/master&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nx">appendFilePath</span> <span class="p">=</span> <span class="kc">true</span>
</span></span></code></pre></div><p>In the broken version, that <code>master</code> was written as <strong><code>main</code></strong>. The repository&rsquo;s default branch has always been <code>master</code>, so <code>blob/main/...</code> naturally does not exist on GitHub.</p>
<p>** The error was a string of characters, not a logic error. ** Hugo does not validate this URL; the template is only responsible for concatenating strings, so the build naturally comes up all green.</p>
<ul>
<li><input checked="" disabled="" type="checkbox"> The concatenated path format is correct</li>
<li><input checked="" disabled="" type="checkbox"> The file exists</li>
<li><input disabled="" type="checkbox"> **No one verified the branch name **</li>
<li><input disabled="" type="checkbox"> And no one clicked the production link</li>
</ul>
<p>*When writing the configuration, I probably just typed the more common term out of habit. *</p>
<h2 id="iii-why-it-wasnt-caught-during-testing">III. Why it wasn&rsquo;t caught during testing</h2>
<p>During the retrospective, what concerns me most isn&rsquo;t the &ldquo;mistake&rdquo; itself, but &ldquo;why it went unnoticed so quietly.&rdquo;</p>
<ol>
<li>**It is pure data **, not code, so static analysis has no way to detect it.</li>
<li>**The feature-check asserts the DOM structure ** (whether <code>a.edit</code> exists, if the class is correct), but it doesn&rsquo;t check external URLs.</li>
<li>Was it clicked locally? **No **. During development, everyone was just looking at the layout.</li>
<li>Netlify only handles the build; it doesn&rsquo;t care where you link to.</li>
</ol>
<table>
	<thead>
			<tr>
					<th>层</th>
					<th>Can detect 吗</th>
					<th>Reason</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Hugo tem板</td>
					<td>No 能</td>
					<td>It only performs string concatenation</td>
			</tr>
			<tr>
					<td>Build val验</td>
					<td>No 能</td>
					<td>It doesn&rsquo;t parse URLs</td>
			</tr>
			<tr>
					<td>feature-check</td>
					<td>No 能</td>
					<td>It asserts selectors, not external links</td>
			</tr>
			<tr>
					<td>Manual click o下</td>
					<td>**Could **</td>
					<td>But it wasn&rsquo;t clicked until three days later</td>
			</tr>
	</tbody>
</table>
<blockquote>
<p>type bugs are roughly formally named &ldquo;the ** cell that no one is responsible for**&rdquo;.</p>
</blockquote>
<h2 id="iv-the-patch-cell">IV. The patch cell</h2>
<p>The fix itself took a second: revert back to <code>master</code>. But building the defense line took a bit of thought.</p>
<p>Added an assertion to <code>feature-check.sh</code> that directly greps the edit links in the build artifacts, ** verifying that the branch segment must equal the repository&rsquo;s default branch **:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">check <span class="s2">&#34;editPost 分支与默认分支一致&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  <span class="s2">&#34;grep -q &#39;/blob/</span><span class="k">$(</span>git symbolic-ref --short refs/remotes/origin/HEAD <span class="p">|</span> sed <span class="s1">&#39;s|origin/||&#39;</span><span class="k">)</span><span class="s2">/&#39; &#39;</span><span class="nv">$PAGE</span><span class="s2">&#39;&#34;</span>
</span></span></code></pre></div><p>Then added a comment next to <code>hugo.toml</code>:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="cl"><span class="c"># 分支必须与仓库默认分支一致（master）——曾误写 main 致全站死链</span>
</span></span></code></pre></div><table>
	<thead>
			<tr>
					<th>Patch 法</th>
					<th>Defends against</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Branch 段  assertion</td>
					<td>If it&rsquo;s written incorrectly again, CI will turn red immediately</td>
			</tr>
			<tr>
					<td>Configuration side note 释</td>
					<td>So people see it before they change it</td>
			</tr>
			<tr>
					<td>Post-mortem written in doc 档</td>
					<td>So next time we don&rsquo;t rely on &ldquo;just a quick click&rdquo;</td>
			</tr>
	</tbody>
</table>
<ul>
<li><input checked="" disabled="" type="checkbox"> Revert back to master</li>
<li><input checked="" disabled="" type="checkbox"> Add assertions (now 27 items)</li>
<li><input checked="" disabled="" type="checkbox"> Add comments</li>
<li><input disabled="" type="checkbox"> While I&rsquo;m at it, scan through other hardcoded domains (added a TODO)</li>
</ul>
<h2 id="v-what-is-more-worth-leaving-behind-than-fixing-a-bug">V. What is more worth leaving behind than fixing a bug</h2>
<p>After this, I changed a habit: ** just building the green pipeline isn&rsquo;t enough; I now always click a production link ** on the fly. It takes three seconds and perfectly covers all the pitfalls of &ldquo;data is wrong but the format is valid.&rdquo;</p>
<p>There is another more general conclusion: ** automatic checks are good at verifying structure, but bad at verifying facts **. If the structure is wrong, it crashes; if the facts are wrong (branch names, domains, dates, IDs), it will fail silently for a long time. Therefore, you should try to mix in some &ldquo;fact-based&rdquo; assertions, even if it&rsquo;s just grepping a string.</p>
<blockquote>
<p>That line of comment is still sitting in the config file. It doesn&rsquo;t execute anything, but every time someone wants to change that URL, they first read &ldquo;Once mistakenly wrote main, causing site-wide dead links.&rdquo;</p>
</blockquote>
<p>** Code manages behavior, comments manage memory. ** This time, I used both.</p>
]]></content:encoded></item></channel></rss>