Engineering Stack Trace Debugging

Stack Trace Analysis Prompt

Read the trace bottom-up, find the frame where the bad value entered, and name what made it bad — the trace is a map, not an answer.

Overview

A stack trace shows the path to the crash — and teams still patch the top frame and move on. This setup analyzes a Python AttributeError from an import job: the trace says .strip() failed on a float at normalize.py line 31, but the investigation asks the real questions — where did a float enter a path that expects strings? which upstream frame stopped enforcing the contract? — tracing the execution path backward and treating the throw frame as the start of the investigation, not the end.

How to use this resource

  1. Paste the whole trace

    Every frame matters — the detector recognizes it, and the analysis walks it bottom-up.

  2. Find the entry frame

    The investigation's pivot: the boundary where the bad value entered the failing path.

  3. Fix at the contract, not the crash

    The repair belongs where the contract broke — usually frames above the throw, sometimes in the data itself.

Why This Works

  • Bottom-up reading turns the trace from a blame pointer into an evidence chain
  • Entry-frame hunting localizes the bug to where it is fixable once
  • Contract framing decides the eternal question: fix the caller or the callee

Best for

  • Crashes deep in utility code that "never changed"
  • Type errors that surface far from their source
  • Import/ETL jobs that die mid-file

Not for

  • Traces from intermittent failures — the intermittent strategy's pattern hunt comes first
  • Minified production JS traces — source-map them before investigating

Use cases

  • Working a traceback to the frame where the bad value entered
  • Finding the implicit contract the crashing code assumed
  • Deciding between fixing the data, the caller, or the callee

FAQ

How does this stack trace prompt avoid just fixing the top frame of the traceback?

The INVESTIGATION FRAMEWORK forces stage 5 ROOT CAUSE ANALYSIS to separate the proximate cause (what threw) from the root trigger (what made it throw), and the ROOT CAUSE RULES state the symptom site and the cause site may be different places. For the sample AttributeError, that means asking where the float entered a path expecting .strip(), not patching normalize.py line 31.

What output format does the debugging-prompt-generator produce for analyzing a crash like this AttributeError?

It produces a prompt that makes the assistant work through ten named stages in order, from SYMPTOMS to POST-FIX VERIFICATION, and label every statement as FACT, ASSUMPTION, or HYPOTHESIS with its test per the EVIDENCE RULES. You copy that prompt and run it in your own assistant; NewPrompt does not run the investigation or confirm the diagnosis.

When should I not use this stack trace analysis prompt?

Skip it for intermittent failures, because this template's VALIDATION REQUIREMENTS lean on the gold standard of a reproduction that turns the failure on and off by toggling the suspected cause. Also skip minified production JS traces until you source-map them, since the bottom-up frame walk needs real file and line names like normalize.py line 31.

Can I use this for a crash that isn't a Python AttributeError from an import job?

Yes — the AttributeError at normalize.py line 31 is a worked example, so replace the KNOWN FACTS block (Symptoms, Actual behavior, the Traceback) with your own trace, and adjust the SYSTEM CONTEXT Reported severity. The DEBUGGING CHECKLIST item on input that violates an implicit contract the code never checks generalizes to any type error surfacing far from its source.

More resources from Debugging Prompt Generator

Resources that pair well

Related tools

Guides for this resource

Tip: Save time by exploring related resources and tools that integrate with this resource.