Skip to content

Codex adapter rejects valid JSONL when one record exceeds hard-coded 16 MiB Scanner limit #7

Description

@chenqianhe

Bug

The Codex adapter fails an entire rollout file when any single JSONL record exceeds the hard-coded 16 MiB bufio.Scanner token limit, even when the file is below the configured watcher file-size limit.

Environment

  • Observer: v1.19.0
  • Platform: macOS arm64
  • Adapter: codex
  • observer.watch.max_file_size_mb = 128

Reproduction

Run:

observer scan --force --adapter codex

Against a valid 91 MiB Codex rollout JSONL containing one 23,355,441-byte record (about 22.3 MiB). The scan reports:

watcher.Scan: process failed adapter=codex err="codex.ParseSessionFile: scan: bufio.Scanner: token too long"

The record contents and local path are omitted for privacy. The failure is reproducible from the measured record length alone.

Root cause

internal/adapter/codex/adapter.go sets const maxLine = 16 * 1024 * 1024 in both the main parser and the session-context prefetch path. Raising observer.watch.max_file_size_mb only passes the outer whole-file guard; it cannot change this per-record limit.

ParseSessionFile returns the scanner error before the watcher ingests the accumulated parse result, so the whole session is skipped rather than only the oversized record.

Expected behavior

Legitimate Codex rollout records within the configured whole-file allowance should be ingestible, or the limit/error behavior should be configurable and explicit.

Suggested fix

Any of these would address the mismatch:

  1. Derive a bounded per-record limit from observer.watch.max_file_size_mb.
  2. Add a separate max_line_size_mb setting.
  3. Replace bufio.Scanner with a reader that supports large newline-delimited records while enforcing an explicit safety bound.

As a minimum compatibility fix, increasing both Codex maxLine constants to 64 MiB would cover this real-world record. A regression test with a valid JSONL record larger than 16 MiB would prevent recurrence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions