Repository navigation
fix(session): tolerate invalid UTF-8 in saved sessions - #39
Closed
jipeng6036-del wants to merge 1 commit into
Closed
jipeng6036-del wants to merge 1 commit into
jipeng6036-del wants to merge 1 commit into
Conversation
Owner
|
Thanks for the catch, @jipeng6036-del. Verified locally: a session file with invalid UTF-8 raises UnicodeDecodeError before json.loads, crashing --resume, and one such file kills the whole /sessions listing. Landed the same fix as my own commit in 1f201a2 with regression coverage for both readers, so closing this one. Credit for the report stands. |
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 saved session containing an invalid UTF-8 byte, or truncated in the middle of a multibyte character, raises
UnicodeDecodeErrorbefore JSON parsing. This crashes--resumeand/sessions, despite the existing handling for corrupt or truncated JSON.Catch
UnicodeDecodeErrorin both session readers: resume returnsNone, and listing skips the unreadable session while retaining valid sessions. The files are left untouched. Four regression cases cover invalid bytes and truncated UTF-8 in both paths, including a valid Chinese-language session alongside a corrupt file.Validation on Windows, Python 3.13.12:
UnicodeDecodeError.python -m pytest tests/ -q: 229 passed.ruff check corecoder tests,python -m compileall -q corecoder tests,python -m build, andpython -m twine check dist/*: passed.AI assistance: this change and its regression tests were prepared with OpenAI Codex.