Repository navigation
Skip non-object rows when decoding session message JSON - #354
Merged
Merged
Conversation
decode_messages_json only skipped null shared_ptrs, so JSON null, strings, numbers, and arrays in a session history became empty-role Message rows on TUI restore. Skip any element that is not a JSON object, matching tool_trace_from_json. Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
This was referenced Sep 18, 2026
…kip-non-objects # Conflicts: # CHANGELOG.md
tylerreckart
marked this pull request as ready for review
September 21, 2026 12:58
tylerreckart
enabled auto-merge (squash)
September 21, 2026 12:58
…kip-non-objects # Conflicts: # CHANGELOG.md
…kip-non-objects # Conflicts: # CHANGELOG.md
…kip-non-objects # Conflicts: # CHANGELOG.md
…kip-non-objects # Conflicts: # CHANGELOG.md
…kip-non-objects # Conflicts: # CHANGELOG.md
…kip-non-objects # Conflicts: # CHANGELOG.md
…kip-non-objects # Conflicts: # CHANGELOG.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.
Problem
decode_messages_json(TUI session / conversation-store restore viaOrchestrator::load_session_json) only skipped nullshared_ptrs in the message array. JSONnull, strings, numbers, booleans, and nested arrays are stored as liveJsonValues, so they were decoded asMessagerows with emptyrole/content.Those empty-role rows go back into the model view on the next turn. Providers reject unknown roles, and compaction / replay treat them as real history.
tool_trace_from_jsonalready skipped non-object entries; the message loop did not.Corrupt or mixed-shape session JSON (
[null, {"role":"user","content":"hi"}]) restored an empty user turn plus the real one. An all-non-object array restored empty-role rows instead of an empty history.Fix
Skip any array element that is not a JSON object. Valid object rows, including those missing optional
thinking/tool_trace, are unchanged. A wholly unreadable blob still fail-closes to{}via the existing parsecatch.Tests
unit_message_codec3/3 locally (13 assertions) + ASan/UBSan. Covers mixed null/string/number/bool/array elements keeping valid objects, all-non-object arrays staying empty, and object round-trip.Independently mergeable against
main(0456350). Code hunks (src/message_codec.cpp, newtests/test_message_codec.cpp+CMakeLists.txttarget afterunit_message_replay_roundtrip) do not overlap #321–#353.git merge-tree --write-treevs those siblings is CLEAN, including CHANGELOG[Unreleased]this run.Note
Low Risk
Narrow decode guard on session JSON restore; valid object messages unchanged, with new unit tests covering edge cases.
Overview
Session restore no longer turns junk entries in stored message JSON into fake chat turns.
decode_messages_jsonnow ignores any array element that is not a JSON object (null, strings, numbers, booleans, nested arrays, sparse null slots), aligned with howtool_trace_from_jsonalready filters trace rows.That stops TUI/conversation restore from rehydrating empty-
roleMessagerows that providers reject and that compaction/replay treat as real history when session files are corrupt or mixed-shape (e.g.[null, {"role":"user",…}]).Adds a focused
unit_message_codecdoctest target (mixed skip, all-invalid → empty vector, encode/decode round-trip) and documents the fix under [Unreleased] in the changelog.Reviewed by Cursor Bugbot for commit 628eb0b. Bugbot is set up for automated code reviews on this repo. Configure here.