Mule · big job

Code Debug: Up to 3 Issues

Paste your broken code and the error, and get back fixed files, a plain-English explanation of each bug, and a change log.

What you get: A Markdown debug report. It includes a diagnosis summary, a root-cause write-up for up to 3 issues, the complete fixed version of every changed file in copy-paste-ready code blocks, a change log table, step-by-step verification instructions, and a short list of any other problems spotted but not fix Price: $49 flat. Time: usually ready in minutes. Done by AI; you review it, with one free change.

We're not taking orders yet. Join the waitlist and we'll email you once when we open.

Real example

This is an actual result our AI made in a test run, from sample details. Yours is made from your details.

Show the example

Debug Report

Stack: Python 3.11, standard library only | Issues fixed: 3 of up to 3

Summary

The report script had three problems. It read dates in day/month/year order, but your file stores them as year-month-day. It also tried to add to each customer's total before that total existed, and it was adding text instead of numbers. Finally, the loop skipped the first order in the file. I fixed all three with small, marked changes, kept both function names, and used only the standard library.

Issues & Root Causes

Issue 1: Date format doesn't match the CSV

  • Symptom: ValueError: time data '2024-03-02' does not match format '%d/%m/%Y'
  • Where: report.py, load_orders(), line 14
  • Root cause: The format '%d/%m/%Y' expects dates like 02/03/2024. Your CSV uses ISO dates like 2024-03-02, which need '%Y-%m-%d'. The error names 2024-03-02 (row 2) rather than 2024-03-01 (row 1), which points to Issue 3: the first row was never read.
  • Fix: I changed the format string to '%Y-%m-%d' so it matches the file.
  • Confidence: High. The traceback and the sample data match exactly.

Issue 2: Totals crash because there's no starting value, and amounts are text

  • Symptom: KeyError: 'Acme Co' in totals_by_customer
  • Where: report.py, totals_by_customer(), line 21. Also load_orders(), line 13
  • Root cause: totals[o['customer']] += ... reads the current total before adding to it. The first time a customer appears, there's no entry yet, so Python raises KeyError. There is a second problem in the same calculation: csv always returns values as text. So 'amount' was the string '120.50', not a number. Even with the KeyError fixed, adding text to a number would crash next with a TypeError, and :.2f can't format text either.
  • Fix: I convert each amount with float(row['Amount']) when loading. I also start each customer at 0 with totals.get(o['customer'], 0) + o['amount']. I counted these two changes as one issue because both are needed before the totals can be added up at all.
  • Confidence: High. Both are standard Python behavior.

Issue 3: The first order is skipped

  • Symptom: The totals looked low.
  • Where: report.py, load_orders(), line 9
  • Root cause: csv.DictReader already uses the header line (Customer,Amount,Date) for the column names. So rows[0] is your first real order (Acme Co, 120.50), not the header. Starting the loop at range(1, ...) threw that order away. That's why Acme Co would have shown $30.00 instead of $150.50.
  • Fix: I changed the loop to range(len(rows)) so it starts at index 0.
  • Confidence: High. This is how DictReader is documented to work, and the clue in Issue 1's error message confirms it.

Fixed Files

report.py

import csv
from datetime import datetime

def load_orders(path):
    orders = []
    with open(path) as f:
        reader = csv.DictReader(f)
        rows = list(reader)
        for i in range(len(rows)):  # FIX 3: start at 0; DictReader already consumed the header line
            row = rows[i]
            orders.append({
                'customer': row['Customer'],
                'amount': float(row['Amount']),  # FIX 2: CSV values are text; convert to a number
                'date': datetime.strptime(row['Date'], '%Y-%m-%d')  # FIX 1: CSV dates are YYYY-MM-DD
            })
    return orders

def totals_by_customer(orders):
    totals = {}
    for o in orders:
        totals[o['customer']] = totals.get(o['customer'], 0) + o['amount']  # FIX 2: start each customer at 0
    return totals

if __name__ == '__main__':
    orders = load_orders('orders.csv')
    for name, total in totals_by_customer(orders).items():
        print(f'{name}: ${total:.2f}')

Files reviewed, unchanged: orders.csv

Change Log

# File Location Change Reason
1 report.py load_orders(), line 14 '%d/%m/%Y' → '%Y-%m-%d' Match the CSV's ISO date format
2 report.py load_orders(), line 13 row['Amount'] → float(row['Amount']) CSV values are strings; math needs numbers
2 report.py totals_by_customer(), line 21 += → totals.get(key, 0) + amount Avoid KeyError the first time a customer is seen
3 report.py load_orders(), line 9 range(1, len(rows)) → range(len(rows)) Stop skipping the first order

How to Verify

  1. Put report.py and orders.csv in the same folder and run:
    python report.py
    
    With the 4 sample lines you pasted (header plus 3 orders), you should see:
    Acme Co: $150.50
    Bolt LLC: $75.00
    
    • No ValueError means Issue 1 is fixed.
    • No KeyError means Issue 2 is fixed.
    • Acme Co at $150.50 rather than $30.00 means Issue 3 is fixed.
  2. Optional automated tests. Save the file below as test_report.py in the same folder and run python -m unittest test_report -v. All three tests should pass.
import os
import tempfile
import unittest
from datetime import datetime

from report import load_orders, totals_by_customer

SAMPLE = (
    "Customer,Amount,Date\n"
    "Acme Co,120.50,2024-03-01\n"
    "Bolt LLC,75.00,2024-03-02\n"
    "Acme Co,30.00,2024-03-05\n"
)

class ReportTests(unittest.TestCase):
    def setUp(self):
        fd, self.path = tempfile.mkstemp(suffix=".csv")
        with os.fdopen(fd, "w") as f:
            f.write(SAMPLE)

    def tearDown(self):
        os.remove(self.path)

    def test_issue1_iso_dates_parse(self):
        orders = load_orders(self.path)
        self.assertEqual(orders[0]['date'], datetime(2024, 3, 1))

    def test_issue2_totals_are_numbers_and_no_keyerror(self):
        totals = totals_by_customer(load_orders(self.path))
        self.assertAlmostEqual(totals['Acme Co'], 150.50)
        self.assertAlmostEqual(totals['Bolt LLC'], 75.00)

    def test_issue3_first_row_not_skipped(self):
        orders = load_ord

Questions

How does the code debug: up to 3 issues work?

You answer a few questions, pay $49, and an AI worker does the job. The result appears on your private page, usually within minutes.

Can I get changes?

Yes. Every job includes one free change request: tell the donkey what to fix and it redoes the job with your notes.

Is it really done by AI?

Yes, fully. No human writes it. AI can make mistakes, so please review the result before you rely on it.

What happens to my information?

It is used only to do your job, is never used to train AI models, and is deleted after 30 days.

What if it fails?

Failed jobs are retried once, then refunded automatically.

Need something different?

Can't find it? Describe anything.

Our AI checks it's something we can do safely, then shows you exactly what you'll get and a flat price. Nothing is charged until you order.

More in Tech & code