<?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>Debugging on Vedant Andhale</title>
    <link>https://www.vedant.me/tags/debugging/</link>
    <description>Recent content in Debugging on Vedant Andhale</description>
    <image>
      <url>https://www.vedant.me/</url>
      <link>https://www.vedant.me/</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 10 Sep 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.vedant.me/tags/debugging/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Debugging by narrowing the question</title>
      <link>https://www.vedant.me/notebook/debugging-without-a-debugger/</link>
      <pubDate>Thu, 10 Sep 2026 00:00:00 +0000</pubDate>
      
      <guid>https://www.vedant.me/notebook/debugging-without-a-debugger/</guid>
      <description>A practical approach to reproductions, hypotheses and boundary checks when stepping through the process is not available.</description>
      <content:encoded><![CDATA[<p>When a debugger is unavailable, it is tempting to scatter print statements through every suspicious function. The output grows quickly, but the question often stays vague: why is this broken?</p>
<p>A better first move is to write down the smallest observable mismatch. “The API is wrong” is broad. “This request returns an empty list when the database contains one matching row” gives the investigation a boundary.</p>
<h2 id="keep-one-reproduction-still">Keep one reproduction still</h2>
<p>Save the request, relevant configuration and expected result. Remove unrelated inputs until the failure stops shrinking. If the problem is intermittent, record what changes between runs instead of silently treating one successful run as a fix.</p>
<p>Then choose one hypothesis. Perhaps the identifier changes type between request parsing and the database query. Check the value and type at those two boundaries. If both are correct, that hypothesis has earned its retirement.</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span>
</span></span><span class="line"><span class="cl">    <span class="s2">&#34;lookup input: request_id=</span><span class="si">%s</span><span class="s2"> customer_id_type=</span><span class="si">%s</span><span class="s2">&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="n">request_id</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nb">type</span><span class="p">(</span><span class="n">customer_id</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>This example deliberately records the type without dumping the entire request. Inspect only the fields needed to answer the question; a diagnostic log should not become a copy of every user&rsquo;s data.</p>
<h2 id="find-the-first-wrong-state">Find the first wrong state</h2>
<p>Trace a short chain: input, parsed value, query parameters, query result, response. If the query result is already empty, changing response serialization is unlikely to help.</p>
<p>For a longer pipeline, inspect the middle first. A correct midpoint moves the search downstream; an incorrect midpoint moves it upstream. You do not need a trace of every line to eliminate half the possibilities.</p>
<p>Once the cause is understood, turn the reproduction into a regression check when the failure is worth protecting against. Remove temporary noise and retain the diagnostic context that would make the same incident understandable next time.</p>
<p>The useful output of debugging is an explanation: this input met this condition, which caused this wrong result. A code change should follow from that explanation.</p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
