Skip to content
Free workshop · 8 cases · about 2 hours

Debug like a detective.

Eight real bugs are hiding in Crumbs, a tiny bakery app. Solve each one with a technique you will use for the rest of your career: tracebacks, failing tests, logging, the debugger, bisection, profiling and plain honest assumptions. Clue keeps score.

Evidence #1

KeyError: 'croissant '
Clue · a ladybug, naturally

Eight open cases.

Each case is a real bug you can run. Every symptom below is real output. Read the evidence, find the culprit, fix the code, and let the checker close the case.

  1. Case 01Read the tracebackThe missing croissantKeyError: 'croissant '
  2. Case 02Reproduce it firstThe customer who was paid to eat680 cents with TENOFF: pay -320 cents
  3. Case 03Print, then logThe points that keep growingreceipt 3: 3 lines, 324 points
  4. Case 04breakpoint() and pdbThe first page of reviewspage 1: review 11 ... 10 reviews
  5. Case 05Divide and conquerOne bad row in two thousandValueError: invalid literal for int() with base 10: 'l2'
  6. Case 06HeisenbugsThe croissant that followed someone homecustomer B: ['croissant', 'baguette']
  7. Case 07Profile, don't guessThe slow regulars report2199 regulars in 4.64 s
  8. Case 08Assumptions lieThe missing cent1000 cents for 3: [333, 333, 333] -> adds up to 999

Run it. Fix it. Close it.

  1. 1detective run 2 watch the bug happen
  2. 2your editor find the culprit and fix it
  3. 3detective check 2 real checks say PASS

Case 02 goes further: the checker runs your own test against the original bug, to prove your test would have caught it.

$ uv run python -m detective check 2

PASS a small order with TENOFF costs 0, not less

PASS your test fails on the original bug

PASS your test passes on your fix

_/\_ (o.o) Case 2 closed. Elementary. (Y)

The detective's checklist.

  1. 1Read the error, last line first
  2. 2Reproduce it as a failing test
  3. 3Watch the values: print, then log
  4. 4Stop and step with breakpoint()
  5. 5Halve the search space
  6. 6Suspect shared state, time and order
  7. 7Measure before you optimise
  8. 8Write your assumptions down
  9. 9Explain it out loud

Start in a minute.

You need uv and git. The lab uses the Python standard library only.

git clone https://github.com/jars-demo/debugging-demo.git
cd debugging-demo/lab
uv sync
uv run python -m detective run 1