16

When I paste a raw stack trace, models tend to fixate on the deepest frame and suggest a fix right there, even when the real cause is three frames up where a bad value was created. The topmost error is a symptom, not always the origin.

I now make it walk the trace outward: separate the throwing frame from the originating frame, trace where the offending value came from, and produce a ranked list of candidate causes with a confidence and a cheap check for each, rather than one confident guess. It's especially good for the "NoneType has no attribute" class of errors where the null was born far from where it exploded.

Sharing the current version. How do you feed it just enough surrounding code without pasting the whole repo?

THE PROMPT
Turn this stack trace into a ranked root-cause analysis. The top frame is a SYMPTOM; find the ORIGIN.

Given:
- Stack trace: {PASTE_TRACE}
- The error and message: {ERROR}
- Any code from frames I include: {PASTE}

Do this:
1. Identify the throwing frame (where it blew up) and separate it from the likely originating frame (where the bad state was created). For a null/None/undefined error, trace backward: where could this value have become bad, and where should it have been validated?
2. Produce a RANKED list of candidate root causes (most to least likely). For each: one-line hypothesis, the confidence (high/med/low), the single cheapest check to confirm it (a value to log, a line to inspect), and the targeted fix IF confirmed.
3. State what additional code you'd need to see to raise confidence, naming the specific function/file - do not ask for the whole repo.
4. Do not propose a fix for anything you rated below 'high' without confirming first.

Rules: no shotgun fixes, no 'try adding a null check everywhere'. The output is a diagnosis to verify, not edits to apply blind.
the 'null was born far from where it exploded' framing finally got a model to look up the trace instead of slapping a guard on the crash site.regex_rob 1 month ago
add a comment

2 Answers

11

The symptom-vs-origin split maps directly to the fix location. I add: 'once the origin is confirmed, state whether the right fix is at the origin (validate/construct correctly) or at the boundary (fail fast earlier), and argue which prevents the whole class of bug, not just this instance.' Pushes it past patching the one crash toward killing the pattern.

10

For feeding surrounding code cheaply: give it just the trace first and let step 3 tell you exactly which 2-3 functions it needs. Paste only those. It turns 'dump the repo' into a targeted request and usually the ranked list is already right after one round of the named functions.

Your Answer