Guide

Debugging is not staring at code until inspiration hits. It is a loop: observe a concrete failure, form a falsifiable hypothesis, run an experiment that could disprove it, narrow the search space, repeat. The goal is the root cause, not the first symptom that went red.

SDE2s are trusted to debug unfamiliar systems without panicking or thrashing. Narrate the loop: current hypothesis, next experiment, what would falsify it. In interviews, walk a past bug with that structure. Interviewers listen for systematic narrowing, not heroics.

Write hypotheses as sentences you can kill. Change one variable per experiment. Keep an audit trail after hour two. If you did not fix the original failure, it is not fixed — do not declare victory on a different symptom. git bisect over 1,000 commits is about 10 builds when the repro is scriptable.

Concepts in this section

Read them in order.

StepConceptWhat it answers
1The scientific loopWhat do you write down before you change anything?
2Reproduce and minimizeHow small can the failing case get?
3Bisecting bugsHow do you cut code, commits, input and config in half?
4Reading the evidenceWhat do stacks, logs, metrics and traces actually say?
5Production debuggingHow do you mitigate without destroying evidence?
6Closing the loopWhat test, note and metric stop this from returning?

A 4 MB upload

API returns 500 for "some" uploads. Binary-search file size: failures start at 4,194,304 bytes. Hypothesis shifts from "virus scan" to "body size limit." The proxy max body is 4 MB. Root cause in minutes, not a day of MIME types. That is minimize-the-input, then one config check — the loop in miniature.

In production, add: scope the blast radius, correlate with deploys and flags, stabilize (rollback or flag off), capture traces, then repro offline. Restarting pods without a hypothesis can destroy evidence. Separate mitigation from the later root-cause fix.

Common mistakes

  • Theorizing without a repro. Especially on races.
  • Changing three things at once. You cannot tell what mattered.
  • Thrashing production. Speculative deploys deepen the outage.
  • Fix without a test. The bug returns after the next refactor.
  • Grep error with no request id. Correlate first.

Key takeaways

  • Observe → hypothesize → experiment → narrow; write hypotheses down.
  • Invest in a reliable, minimized repro; bisect across code, commits, inputs and config.
  • In production: correlate, mitigate safely, preserve evidence.
  • Ship the fix with a regression test and a short write-up.
  • When stuck, restate facts, kill hypotheses, compare working vs broken, then ask for help with an audit trail.

Further learning

A walkthrough of git bisect:

Using git bisect to pinpoint bugs in your commit historyJim Hester
A debugging manifesto (Julia Evans)A debugging manifestoJulia Evans Debugging: The 9 Indispensable Rules (David Agans)Debugging Rules! – Find out what's wrong with anything, fast.debuggingrules.com