Debug an error by root cause, not guesswork
FreePaste an error and its context to get a traced root-cause diagnosis, a fix that addresses the real cause, and a concrete way to verify the bug is gone.
A root-cause diagnosis of your error — the single most probable underlying cause, the fix, and how to confirm it worked — instead of trial-and-error patches that only move the symptom around.
This prompt
You are a senior software engineer who debugs by evidence, tracing every failure back to its true root cause instead of patching the symptom.
Diagnose the error below and identify the single most probable root cause, then give a fix and a concrete way to verify it. You succeed when the fix removes the underlying cause (not just the visible symptom) and you name a check that would prove the bug is gone.
Error message / stack trace:
<<<
{{error_message}}
>>>
Context — language/framework, what changed recently, expected vs. actual behavior, how to reproduce, and any relevant code:
<<<
{{context}}
>>>
Work through it like this:
1. Read the error in full — every word, the exact file and line, and the innermost frame of any stack trace. Restate what it literally says.
2. Trace backward from where the error surfaced to where it originated: name the immediate cause, then ask "what produced that bad value or state?" and follow the invalid data up the call chain to the original trigger. The reported line is usually where the failure showed up, not where it began.
3. List 2-4 candidate causes that fit the evidence. For each, note what in the error or context supports it or rules it out.
4. Choose the single most probable root cause. State it as an underlying condition — a wrong assumption, a missing guard, a changed data contract, a config or environment difference, a race — not "the code is broken." Confirm it is actionable, explains every symptom, and, walked backward, logically produces the observed error.
5. Give the fix that removes that cause. Prefer the smallest change that addresses the root rather than masking the symptom.
6. Give a verification step: the exact command, test, or observation that shows the bug is gone, and what a passing versus failing result looks like. Prefer a check that would have failed before the fix.
Output using these sections:
- What the error is saying — 1-2 plain sentences.
- Most probable root cause — one clear statement plus why the evidence points here.
- Other causes considered — brief bullets, each with why it is less likely.
- Fix — what to change and where; include code only when the change is concrete.
- How to verify — the exact check and its expected result.
- Confidence and unknowns — high / medium / low, plus anything that would change the diagnosis.
Constraints:
- Base every claim on the provided error and context. Do not invent file names, code, or values that were not given.
- If the evidence is genuinely insufficient to isolate one cause, say "I need more info," name your top 1-2 suspects, and state the exact detail you would need — a log line, a value, the failing input, a version — to decide. Do not guess a fix.
- Commit to one primary root cause and one fix; keep alternatives in their own section.
- Diagnose the underlying condition, not the person — skip blame.2 fields still empty — the {{like_this}} slots fill in as you type.
See it in action
What this prompt produces with example details filled in:
What the error is saying
- `formatPrice` (checkout.js:42) was called with `price` equal to `undefined`, and calling `.toFixed(2)` on `undefined` throws. React then unmounts the whole tree, which is why the cart page goes white instead of showing one broken row.
Most probable root cause
- Deals items from the v2 API carry their amount in a `salePrice` field, not `price`, so `item.price` is `undefined` for those items. `CartSummary` still reads `item.price` and passes it straight into `formatPrice`, which assumes a number. The v2 migration changed the data contract; the component was never updated to the new field. Walked backward: crash at `.toFixed` <- `price` is `undefined` <- `item.price` is missing on deals items <- v2 returns `salePrice` instead of `price`. This explains both clues: it began exactly at the v2 cutover, and only deals items crash.
Other causes considered
- A genuinely empty/null-priced product: less likely — the crash started precisely at the v2 migration and is scoped to deals items, not random ones.
- Async/race where the price loads after render: ruled out — the field is simply absent in the payload, not late; regular items with `price` render immediately.
- A regression inside `formatPrice`: ruled out — the function is unchanged and works for every item that still has a `price`.
Fix
- Normalize the price field at the data boundary where cart items are built from the API response, so the component always receives one shape:
`const price = item.price ?? item.salePrice;`
Pass that normalized value into `CartSummary`. As a backstop, make `formatPrice` guard against a non-number before formatting so a future missing field degrades gracefully instead of white-screening the page.
How to verify
- Add a deals item to the cart and open the cart: the summary should render the sale price (e.g. `$19.99`) with no white screen. Add a regression test that renders the cart for an item shaped `{ salePrice: 19.99 }` (no `price`) and expects `19.99`. That test throws on the current code and passes after the fix.
Confidence and unknowns
- High. One thing to confirm: that `salePrice` is a number (e.g. `19.99`) and not a preformatted string like `"$19.99"`. If v2 sends a string, coerce with `Number(...)` before `.toFixed`, otherwise you will trade this crash for `NaN`.Tips
- Paste the full stack trace, not just the top line — the innermost frame usually names the origin.
- In context, include what changed recently (a deploy, a dependency bump, a config edit); most bugs start there.
- State what you expected versus what happened and how to reproduce it — that is what separates a root cause from a guess.
- If it replies 'I need more info,' give the exact log line or value it asks for and run it again rather than accepting a guessed fix.
Built by Web Innoventix
Want the work done, not just prompted? We design, build and rank websites that get found on Google and cited by AI.
Get a free quoteMore prompts
Browse all →Build a React component from a description
Turn a plain-English description into a production-ready, accessible React + Tailwind component with a usage example.
Senior code review that catches real bugs
Paste a snippet or PR diff and get a senior-engineer review: real issues ranked by severity, each with the exact input that breaks it and a concrete fix — not a wall of style nitpicks.
Write thorough unit tests for a function or component
A fill-in prompt that turns any function or component into a runnable unit test suite covering happy paths, edge cases, boundaries, and error handling in your chosen framework.
Refactor a messy function into clean, maintainable code
A copy-paste ChatGPT prompt that refactors a messy function into clean, maintainable code without changing its behavior — it audits the code, rewrites it, explains each change, and suggests tests to prove nothing broke.
Build a regex from a plain-English description (with test cases)
A fill-in-the-blank ChatGPT prompt that turns a plain-English rule into a working regex for your exact language — with a line-by-line breakdown and a pass/fail table of positive and negative test cases.
Write a clear, conventional git commit message from a diff
A fill-in prompt that turns any git diff into a clean, convention-compliant commit message with a tight subject line and a what-and-why body a reviewer can trust.

