fix(normalize): handle UTF-8 BOM in transcript files - #1102
Conversation
527b70b to
95ef478
Compare
|
Friendly ping — this one's been quiet since I opened it. CI is green across all 6 checks (linux 3.9/3.11/3.13, windows, macos, lint). Happy to adjust scope or rework the approach if a different fix shape works better here. |
95ef478 to
3e0e86a
Compare
|
Second ping after a week. CI is green across all 6 checks, no conflicts, the change is a single-character fix ( @igorls — pinging you given the recent encoding/durability cluster activity (#1214/#1215 merged, #1408/#1409 follow-ups in flight). Happy to adjust scope or approach if a different fix shape would be preferred. |
|
Rebased on |
3e0e86a to
75b31b7
Compare
|
Friendly ping — post-3.3.6 release this is still mergeable on |
Windows exports of Claude Code JSONL sessions prepend a UTF-8 BOM (\xef\xbb\xbf). With encoding='utf-8', json.loads() raises JSONDecodeError on the first line, _try_claude_code_jsonl silently skips every line, and the file falls through as raw text — losing all structured message content. utf-8-sig strips the BOM transparently and is backward-compatible with BOM-free files on all platforms.
75b31b7 to
818e4f3
Compare
What and Why
normalize()opens transcript files withencoding='utf-8'. When a file has a UTF-8 BOM prefix (\xef\xbb\xbf) — common from Windows exports of Claude Code JSONL sessions —json.loads()raisesJSONDecodeErroron every line because the first line starts with{._try_claude_code_jsonlsilently skips all lines and the file falls through as raw unstructured text, discarding all message content.Root Cause
normalize.py:124—encoding="utf-8"does not strip the BOM;encoding="utf-8-sig"does.Fix
Python's
utf-8-sigcodec strips the BOM on read and is fully backward-compatible with BOM-free files. No behavioral change on Linux/macOS files.Reproduction
Tests
All 107
test_normalize.pytests pass. All 1066 tests pass.Closes #1034 (partial — encoding fix for
normalize.py; other files addressed in separate PRs)