Module 01 · Read the error before you re-prompt
Traceback Anatomy
Stop pasting the whole stack trace back into the chat. Learn to read a traceback bottom-up, find the one line that matters, and describe the failure precisely.
When generated code throws, the instinct is to copy the entire red wall of text back to the model and hope. You can do better in about ten seconds. A Python traceback is a structured story, and it reads from the bottom up.
The last line is the verdict: the exception type and message. Everything above it is the path the program took to get there, most recent call last. Your job is to find the deepest frame that is your code, not the library's.
A traceback, read bottom-up
Traceback (most recent call last): File "app/server.py", line 42, in handle_request return build_response(payload) File "app/render.py", line 18, in build_response name = data["user"]["name"]KeyError: 'user'// click a numbered line to read the annotation
The three questions
1. What broke? Read the bottom line. `KeyError: 'user_id'` is a different problem from `KeyError` on a dict you built yourself versus one the framework handed you.
2. Where is my code? Scan up for the last frame in a file you wrote, not in site-packages. That is usually the real culprit.
3. What was the value? The message names the offending key, index, or type. That noun is your search term and your re-prompt.
The same bug, defended
def build_response(data: dict) -> dict: user = data.get("user") if user is None: raise ValueError( "payload missing 'user'; got keys: " f"{list(data.keys())}" ) return {"greeting": f"Hi {user['name']}"}// click a numbered line to read the annotation