Bug fixing is scientific, not random code tweaking.
The process: Report → Reproduce → Isolate → Hypothesize → Observe → Fix → Test → Verify → Regression Test
A good bug report includes: expected behavior, actual behavior, reproduction steps, environment/version, sample input, and evidence.
Rules:
- Before fixing a bug, reproduce it or gather sufficient evidence.
- Distinguish between correlation and cause.
- Test one hypothesis at a time, rejecting or confirming it with evidence.
- Apply the smallest fix that addresses the root cause.
- A regression test must fail before the fix and pass after it.
- Verify that the fix doesn’t break other behavior.
Advanced Root Cause Analysis (RCA)
A symptom is what we observe; a root cause is the mechanism that, if fixed, prevents the issue from recurring.
Example: A timeout is a symptom; a missing index, lock contention, a query without a WHERE clause, or a retry storm could be the root cause.
RCA tools:
- Five Whys, grounded in evidence, not guesswork;
- Event timeline;
- Diff between a healthy and a broken version;
- Logs, metrics, traces, and correlation IDs;
- Git bisect to find the introducing commit;
- Minimal reproduction;
- Fault tree for multiple probable causes.
A professional RCA output includes:
- Impact and scope;
- Timeline;
- Technical root cause and contributing factors;
- Evidence;
- Immediate fix;
- Preventive actions;
- Method for verifying the fix.
Go beyond saying “fixed by adding a null check”; ask why the null reached that point and why the contract or a test didn’t catch it earlier.