fix(ast_parser): parse_structure has no exception handling around parser/handler — crashes dir loop on malformed input #82
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
parse_structure()wraps the file read intry/except OSError, but the tree-sitter parse and the language handler are unprotected:luminos_lib/ast_parser.py:306-314:The caller
_tool_parse_structure(ai.py:286-292) doesn't wrap either — so any exception propagates up into_run_dir_loopand crashes the per-directory investigation.Why this matters
parse_structureon any file it thinks is source, including ones it hasn't verified — so the unsafe paths are reachable from the agent's normal tool useCLAUDE.md requires "Graceful degradation everywhere … individual dir-loop failures — all handled without crashing the run." A tool that raises breaks that contract.
Fix
Wrap lines 312-313 in try/except Exception and return an error string:
A returned error string is the established pattern for every other tool in
ai.py.Acceptance
parse_structurenever propagates an exception out to the callerast_parser.pystays exempt from unit tests (CLAUDE.md), but a smoke test via_tool_parse_structureintest_ai_pure.py(feeding a crafted input) is welcome