ChatGPTDebuggingLevel 2: Context

What Should You Paste Into ChatGPT to Fix an Error?

Paste the exact error text, the full stack trace, the command you ran, and the code at the failing line. Add what you expected to happen. Take out any secrets first. OpenAI's Prompting guide says the reproduction steps and constraints you supply matter more than a high-level description.

Prompt to copy
I'm getting this error:

```
[paste the full error and stack trace, unedited, with secrets replaced by FAKE]
```

Command I ran: [exact command]
Environment: [language and version, framework and version, OS]
Expected: [what should have happened]
It started after: [your last change, or "unknown"]
Code at the failing line:

```[language]
[paste the function, not the whole file]
```

Explain what the error means and the most likely cause, and say how sure you are. Give the smallest fix. If you need another file or a value to be sure, ask for it. Don't guess.
Do
  • The exact error and full trace
  • The command you ran
  • The code at the failing line
  • Take out any secrets first
Don't
  • "It doesn't work"
  • Your guess at the cause
  • A screenshot with no explanation
A rule of thumb based on OpenAI's advice about reproduction steps.

Try it now

  1. 1Take a real error from your terminal or browser console, and copy all of it, starting from the first line.
  2. 2Replace any keys, tokens or customer details, then paste it into the prompt above in New chat.
  3. 3It worked if the answer names the failing line and a cause you can check. If it lists five possible causes, send the missing detail it needs, and ask again.

Use it when

Any time there's an error message, a failing test, or a log line, including build errors and failed deploys. If the problem is a wrong result with no error, paste the input, the output you got and the output you expected.

Skip it when

Skip the full paste if your log contains customer data or credentials you can't remove. Describe the shape of it and replace values with fakes. OpenAI's pricing page lists content on personal plans as used for training unless you opt out, so don't paste what you wouldn't want to be stored.

Why it works

An error message names a file, a line and a type, and those are facts ChatGPT can reason from. A summary in your own words has already dropped them, and it can pass along your wrong guess about the cause.

In Codex, OpenAI's guide takes this further. Its bug-fix example asks Codex to reproduce the bug locally first, then propose a patch and run checks. Codex can do that because it runs commands in your workspace. In Chat, it can't run your project, so the text you paste is all it has.

For errors you only see on screen, OpenAI's Image inputs page shows codex -i screenshot.png "Explain this error and suggest the smallest fix", and warns not to rely on the image alone. Say what to look at. Text is still better when you can copy it, since a screenshot can cut off a long trace.

Example

Your Node app fails with TypeError: Cannot read properties of undefined (reading 'id') at orders.js:42. "My orders page crashes" gets you general advice about null checks. The trace, the handler around line 42, and the fact that it only fails for guest checkouts point straight to the question that matters: where does req.user come from when nobody is logged in?

Going further

In Codex, you often don't need to paste the code. Point to the failure and let it read the repo, using @ to insert a file path. codex --image adds a screenshot to the first prompt, and codex exec - reads a whole prompt from stdin, so you can pipe in a long log. Then ask for the same check to run after the fix: OpenAI recommends re-running reproduction steps and the relevant checks. Avoid exposing keys while you do this. OpenAI's non-interactive page warns against setting OPENAI_API_KEY or CODEX_API_KEY as a job-level variable in workflows that run repository-controlled code.

Common mistakes

  • Pasting only the last line of the trace. The first frame in your own code is often the most useful line.
  • Retyping an error from memory. A slightly different wording can send it toward a different problem.
  • Leaving out versions. The same message can have different fixes on different releases.
  • Pasting a .env file or a live token along with the log. Rotate any key that you pasted by accident.

Sources

Checked 6 November 2026. Products change often, so confirm details with the vendor.

Related

Beyond the course