Repository navigation
trace: skip JSON lines that are not objects when reading a transcript - #150
Merged
SakshamUboweja merged 1 commit intoNov 6, 2026
Merged
Conversation
A transcript reader calls .get on whatever json.loads returns. A line that is valid JSON but not an object (null, 42, "text", []) has no .get, so the reader raised AttributeError and one such line discarded the whole log. Check isinstance(ev, dict) after parsing and skip the line, as opencode.py and the other Claude readers already do. This covers claude_calls, claude_session_usage, the Codex rollout and exec readers, the Copilot readers, both tool-catalog parsers, the loop guard's completed_calls and the Codex capability audit. Follows microsoft#40 and microsoft#41 by 1aifanatic.
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.
A transcript reader parses each line with
json.loadsand calls.geton the result. A line that is valid JSON but not an object (null,42,"text",[]) has no.get, so the reader raisesAttributeError, and one such line discards the whole transcript. For example,load_trajectoryon a log with anullline between two tool calls raises instead of returning the two calls.The readers in
opencode.pyand the other Claude readers already checkisinstance(ev, dict). This PR adds the same check to the 13 places that miss it:claude_calls,claude_session_usage, the 5 Codex readers,copilot_event_calls,copilot_session_cwd, both tool-catalog parsers, the loop guard'scompleted_callsand the Codex capability auditinspect_usage. A non-object line is skipped, and the valid lines around it read as before. The check covers the top-level record only, not nested fields.This is #40 and #41 by 1aifanatic, which were closed with the other ungrouped submissions. The fix is the same idea as #41. I left out
microskills/distiller.py(load_calls), which has the same gap, because #134 and #141 change that file. I can add it after they land.The tests are in the existing
tests/test_trace.py. Each of the 5 tests puts 4 non-object lines before and after valid records and checks that the result equals the result for the valid records alone. One array line holds every marker string that a reader checks before it parses, so each reader reachesjson.loadswith a non-object line.How it was produced: Claude Code, an AI coding agent, found the bug by reading the readers after #132 and wrote the fix and the tests. I directed the work and ran the checks below.
What was verified, on macOS with Python 3.12.0, on
mainat519c65f:python -m pytest tests/test_trace.py -k non_objectreports 5 failed. Each fails with anAttributeErrorat the.getcall on the non-object line, for example'NoneType' object has no attribute 'get'atclaude.py:36.tests/test_trace.pyreports 25 passed.python -m pytest tests -rfEs --tb=linereports 702 passed, 15 skipped and 0 failed. Each skip needs a tool that the machine does not have, for example a real Codex, Hermes or opencode CLI.mainhas moved to1b02972(microskills: don't report a tool as missing when python -m or uvx runs it #139) since. The branch merges cleanly with it, because microskills: don't report a tool as missing when python -m or uvx runs it #139 touches other files.Risk: a non-object line was never a record, so skipping it cannot change a result that was correct before. It only stops an exception.