Add structured error location reporting to execution errors (D128) - #258
Open
isaacbrodsky wants to merge 5 commits into
Open
Add structured error location reporting to execution errors (D128)#258isaacbrodsky wants to merge 5 commits into
isaacbrodsky wants to merge 5 commits into
Conversation
Rework of the stale draft that became PR #25. A run failure's red overlay led with the runner's own frame (_child.py's `fn(**bind_params(...))`) and buried the user's actual line further down. Now the traceback starts at the caller's code and a structured `where` points straight at the failing line. - _binding.py: shared `trim_harness_frames` + `user_location`, used by both built-in execution paths so they report failures identically. - _child.py (subprocess/user code) and executor.py `_run_inprocess` (in-process first-party helpers): trim leading runner frames (this module, _binding.py, `<frozen importlib>`); harness-raised errors (bad params, missing main, unserializable return) format as the exception line only; add `error.where` = {file, line, func, source} of the deepest frame in the user's own file, or null when the error never touched it. - executor.py `_error()` (missing file, timeout, worker crash): where=null. - engine.py (fused engine): text-based `_user_location` over the cleaned traceback string, matching the same semantics — one wire shape (PY-14). - runtime.js overlay + api/template.html: headline `<file>, line N, in <func>` + the source line above the traceback. Additive wire change; existing {type,message,traceback} consumers unaffected. - Docs: ARCHITECTURE, SPEC (RH-3/PY-14), SKILL, and DECISIONS D128 (renumbered from the draft's D72, since taken by the in-process split; reconciled against the _binding.py extraction and the in-process path). - Tests: new tests/test_executor.py (real subprocesses) + engine `where` cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ad7XvN7x4887vZoe4VP24h
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||
After trimming, the traceback already leads with the user's failing frame, so the where headline rendered inline above it duplicated that line (and its source) for errors raised directly in user code. Make the headline the prominent culprit and tuck the full traceback behind a collapsed `Traceback` toggle on both surfaces (runtime overlay + api card). When there is no `where` (harness error, timeout, missing file) the traceback shows outright, since it is the only content. Display-only — the wire shape is unchanged. Docs: ARCHITECTURE error-overlay bullet, SKILL, DECISIONS D128. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ad7XvN7x4887vZoe4VP24h
Bugbot (PR #258): a SyntaxError always sets `where`, so the previous commit collapsed its traceback behind the toggle. But that traceback is the `format_exception_only` caret block, and its `^` column marker (the exact bad token) is not captured in `where` — so the caret was hidden by default on a common failure path. Fix: for a SyntaxError/IndentationError/TabError, show the traceback outright with no headline (the caret block already names file/line/column and is a better pointer than the headline we build). Runtime errors keep the headline + collapsed traceback. Both surfaces (overlay + api card). Docs: ARCHITECTURE, DECISIONS D128. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ad7XvN7x4887vZoe4VP24h
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 214be36. Configure here.
…ct-all Collapsing the traceback behind a <details> hid it with display:none, which the browser also excludes from select-all/copy — so copying the whole page (e.g. to paste into an AI) lost the full stack. Fix, both surfaces (runtime overlay + api card): - Add a "Copy error" button that writes the entire debug message (type + message + full traceback) to the clipboard (clipboard API, with a hidden-textarea + execCommand fallback for the sandboxed iframe / non-secure origins). Guaranteed way to copy everything regardless of what's on screen. - Replace the display:none collapse with an sr-only (clip-rect) <pre>: the traceback is invisible on screen but STILL captured by a whole-page select-all, and it's one node so expanding (Show traceback) never double-copies. Verified in Chromium that clip-rect survives select-all where display:none / <details> do not. Headline stays primary; SyntaxError caret block and no-`where` errors still render outright. Docs: ARCHITECTURE, DECISIONS D128, SKILL. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ad7XvN7x4887vZoe4VP24h
…5-relevance-j2yr05 # Conflicts: # DECISIONS.md # skills/fused-render-authoring/SKILL.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This change adds structured error location information (
where) to all execution error responses, allowing the UI to highlight the exact line of user code that failed. Both the subprocess and in-process execution paths now report errors uniformly with file, line number, function name, and source code snippet.Key Changes
Error response shape: Added
wherefield to error objects in all execution paths.whereis eithernull(for harness/infrastructure errors) or a dict with{file, line, func, source}pointing to the deepest user-code frame.Shared error diagnostics (
_binding.py):trim_harness_frames(): Strips leading runner/bootstrap frames from tracebacks so user code is prominentuser_location(): Extracts the deepest frame in the user's script as a structured location dict, handling both runtime exceptions and SyntaxErrorsSubprocess execution (
_child.py):trim_harness_frames()anduser_location()to build clean tracebacks and error locationsformat_exception_only()for harness errors (no stack) andformat_exception()for user errors (with trimmed stack)In-process execution (
executor.py):Fused engine (
engine.py):_user_location()to parsewherefrom already-formatted traceback strings (text-based counterpart to live exception handling)UI updates (
runtime.js,template.html):whereinformation prominently above the full tracebackTests (
test_executor.py,test_engine.py):where=nulland user errors point to the correct frameImplementation Details
_binding.pyto ensure consistent error reportingmain, unserializable return) havewhere=nulland no stack tracehttps://claude.ai/code/session_01Ad7XvN7x4887vZoe4VP24h
Note
Low Risk
Additive error payload and UI-only display changes; existing consumers that ignore
wherekeep working, with broad test coverage on both execution paths.Overview
Python run failures now return a structured
where(file,line,func,source) on the deepest frame in the user script, withtracebacktrimmed so it no longer leads with_child.py/ executor harness frames. Harness-only failures (bad params, missingmain, timeouts, missing file) keepwhere: nulland often a message-only traceback.Shared helpers
trim_harness_framesanduser_locationin_binding.pydrive both the subprocess worker and in-process executor; the fused engine adds_user_locationto parse the same shape from cleaned traceback text. Specs, architecture notes, and authoring docs are updated for the wire shape (PY-14 / RH-3).runtime.jsand the API inspector template headline the failing line whenwhereis present, collapse the full traceback behind Show traceback (sr-only so select-all still copies it), and add Copy error. Newtests/test_executor.pyand engine tests cover deepest-frame semantics, library errors blaming the caller, syntax errors, and harness cases.Reviewed by Cursor Bugbot for commit 31bc606. Bugbot is set up for automated code reviews on this repo. Configure here.