fix: don't split session JSONL on Unicode line separators#354
Merged
alejandro-ao merged 1 commit intoJul 19, 2026
Merged
Conversation
rian-dolphin
marked this pull request as ready for review
July 13, 2026 14:24
Pydantic's dump_json escapes only C0 control characters, so U+2028, U+2029, and U+0085 in message content are written literally to session files. The readers used str.splitlines(), which treats those characters as line boundaries, splitting one valid JSON line into two malformed fragments — after which every load of the session raised SessionJsonlError. Split on \n only, the actual JSONL delimiter. Unescaped U+2028 is valid JSON, so this read-side fix also repairs already-affected session files. The same pattern in SessionManager._read_index is fixed too, where a session title containing such a character broke the index.
alejandro-ao
force-pushed
the
fix/unicode-line-separators-in-jsonl
branch
from
July 19, 2026 15:36
aa7cb21 to
2386293
Compare
alejandro-ao
approved these changes
Jul 19, 2026
alejandro-ao
left a comment
Collaborator
There was a problem hiding this comment.
looks great. thanks!!
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.
Session files are JSONL, but the reader split them with str.splitlines(), which also breaks on U+2028/U+2029/U+0085. These are characters pydantic writes unescaped into JSON strings. One message containing such a character (e.g. from a file read into a tool result) splits a valid line into two malformed fragments, so every subsequent session load/resume raises SessionJsonlError — the session is permanently bricked. Fix: split on \n only, which also retroactively repairs already-broken files; same bug fixed in the session index reader.
To reproduce, run this snippet on main (fails with
SessionJsonlError) and on this branch (prints one entry). Note the append succeeds either way — the corruption is only visible on the next read, and typing/pasting the character into the TUI won't trigger it because the input path sanitizes it; the script drives the storage API directly, as a tool result would: