Bug Report
Description
Session resume fails with SyntaxError: Unterminated string in JSON when the events.jsonl file contains raw U+2028 (Line Separator) or U+2029 (Paragraph Separator) characters inside JSON string values.
These Unicode characters are valid within JSON strings per RFC 8259, but JavaScript JSON.parse() (pre-ES2019 behavior) and some streaming JSONL parsers treat them as line terminators, which breaks mid-string parsing.
Steps to Reproduce
- In a Copilot CLI session, paste text containing a raw U+2028 character (e.g., copied from a rich-text source or certain editors)
- The character gets stored verbatim in
events.jsonl inside a user.message event
- End the session
- Try to resume the session
Error Message
Failed to resume session: Error: Session file is corrupted
(line 2443: SyntaxError: Unterminated string in JSON at position 201 (line 1 column 202))
Root Cause
Line 2443 of events.jsonl contained 3 raw U+2028 characters within the content field of a user.message event. While valid JSON per RFC 8259, the JSONL parser being used treats U+2028/U+2029 as line terminators, splitting the JSON string mid-value and causing the "unterminated string" error.
Workaround
Replace raw U+2028/U+2029 with their escaped equivalents in the events file:
content = content.replace("\u2028", "\\u2028")
content = content.replace("\u2029", "\\u2029")
Suggested Fix
Either:
- Sanitize on write: When serializing events to JSONL, escape U+2028/U+2029 characters in string values (many JSON serializers have options for this, e.g.,
JSON.stringify with a replacer)
- Use a compliant parser: Ensure the JSONL reader uses ES2019+
JSON.parse() which correctly handles U+2028/U+2029 inside strings (Node.js 10+ supports this natively)
- Sanitize on read: Before parsing each JSONL line, replace raw U+2028/U+2029 with escaped equivalents
Environment
- Copilot CLI version: 1.0.22-0
- Node.js: (built-in)
- OS: Linux (Ubuntu)
- Session ID:
a6c1b6b2-c1f8-4aa7-863a-8a55ba221c25
Labels
bug, session-management
Bug Report
Description
Session resume fails with
SyntaxError: Unterminated string in JSONwhen theevents.jsonlfile contains raw U+2028 (Line Separator) or U+2029 (Paragraph Separator) characters inside JSON string values.These Unicode characters are valid within JSON strings per RFC 8259, but JavaScript
JSON.parse()(pre-ES2019 behavior) and some streaming JSONL parsers treat them as line terminators, which breaks mid-string parsing.Steps to Reproduce
events.jsonlinside auser.messageeventError Message
Root Cause
Line 2443 of
events.jsonlcontained 3 raw U+2028 characters within thecontentfield of auser.messageevent. While valid JSON per RFC 8259, the JSONL parser being used treats U+2028/U+2029 as line terminators, splitting the JSON string mid-value and causing the "unterminated string" error.Workaround
Replace raw U+2028/U+2029 with their escaped equivalents in the events file:
Suggested Fix
Either:
JSON.stringifywith a replacer)JSON.parse()which correctly handles U+2028/U+2029 inside strings (Node.js 10+ supports this natively)Environment
a6c1b6b2-c1f8-4aa7-863a-8a55ba221c25Labels
bug, session-management