Skip to content

Session JSONL parser crashes on U+2028/U+2029 (Unicode Line/Paragraph Separators) in user messages #2607

@KarnikJain

Description

@KarnikJain

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

  1. In a Copilot CLI session, paste text containing a raw U+2028 character (e.g., copied from a rich-text source or certain editors)
  2. The character gets stored verbatim in events.jsonl inside a user.message event
  3. End the session
  4. 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:

  1. 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)
  2. 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)
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions