Fixing a Bug
The fundamentals ended with talking through your work and managing time. This page puts them to work on the most common task in AI coding rounds: "fix this bug". It's also the task where the AI is most tempting to trust, because it will hand you a confident diff that makes the symptom go away within seconds. Interviewers build bug tasks to separate candidates who debug from candidates who accept that diff.
The running example is a made-up shop backend with a daily sales report, and this bug report:
Store managers in California say orders placed in the evening show up on the next day's report.
Reproduce It Before You Theorise
Make the bug happen before you look for its cause. A bug you can't reproduce is a bug you can't prove you've fixed, and the interviewer will ask how you know. Reproducing first also catches the case where you misread the report and were about to fix the wrong thing.
Start with the cheapest reproduction you can find. Run the existing suite first, since the bug is sometimes already caught by a failing test. If not, call the function directly with the smallest input that shows the problem, and write that call as a new test. That test does double duty: right now it shows the bug, and later it's your regression test. The AI writes this well if you tell it the input, the expected output and the reason:
Weak: "Write a test for the daily report bug."
Better: "Write a failing pytest for
daily_totalsintests/test_daily_report.py. One order for a store inAmerica/Los_Angeles, created at 2026-03-04 05:30 UTC, which is 21:30 on March 3 local time. Assert it's counted on March 3. Use the existingmake_orderfixture and don't change any non-test files."
Run it and watch it fail. If it passes, stop: either the bug lives somewhere else or you've misunderstood it. At work you might jump straight to the code you suspect because you know the system. In the interview you don't know the system, and a failing test is the only evidence the interviewer can see.