Debugging across a repository
Send Gemini 3.1 Pro Preview the relevant part of a codebase together with the failing test and the error, and ask where the fault starts and which files the fix touches. Have it cite file paths and line ranges so you can check each claim.
Example: Where does this rounding bug start?
Material
- Failing test
- test_invoice_total: expected 3.35, got 3.34 for three lines of 1.115 (prices have three decimals).
- Code
- invoices/total.py: total = round(sum(float(l.amount) for l in lines), 2)
PromptFind where the total stops matching the expected value, name the file and function where the bug starts, and propose the smallest fix.
Sample answer · written by hand to show the reasoning
The bug starts in invoices/total.py, where each amount is converted to float before summing. 1.115 has no exact binary value, so three of them add up to 3.3449999…, and round() takes that down to 3.34; summed as Decimal the total is 3.345, which rounds half up to 3.35. Keep amounts as Decimal end to end and round the sum once with quantize(Decimal("0.01"), ROUND_HALF_UP).