Commit 8c831cb
committed
fix: skip corrupt/truncated lines in import_session_to_store
_append_jsonl_file_in_batches parsed each line with a bare json.loads(line),
so a partially-written final line — the normal outcome when the CLI is killed
mid-append to a .jsonl — made import_session_to_store raise json.JSONDecodeError.
Every read path in the package tolerates this: _parse_transcript_entries (used
by get_session_messages) wraps json.loads in try/except and skips corrupt
lines, so the same file reads fine. Because entries flush in batches, a large
session also left the store partially populated before the crash.
Skip corrupt/truncated lines to match the read path. import_session_to_store's
documented Raises (ValueError, FileNotFoundError) already excludes
JSONDecodeError, so this aligns behavior with the contract. Adds a regression
test.1 parent 5513b20 commit 8c831cb
2 files changed
Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
140 | 147 | | |
141 | 148 | | |
142 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
112 | 136 | | |
113 | 137 | | |
114 | 138 | | |
| |||
0 commit comments