Repository navigation
Description
What happened?
ccusage aborts when a Codex JSONL record ends in a truncated "type" field. I reproduced this with my local logs on 20.0.45 and 20.0.48:
range start index 227 out of range for slice of length 226
Aborted (core dumped)
codex_line_type_flags can advance start to line.len() + 1 after a missing value or opening quote, then index line[start..] on its next iteration. This happens before the JSON parser can skip the malformed record. The release profile uses panic = "abort", so one record terminates the whole report.
I have implemented a small bounds check and a fixture regression test: patch 8c8cd6a. The regression failed before the fix and passes afterward, preserving valid usage around malformed records. Full Rust workspace tests, Node tests, Rust formatting, and Codex Clippy passed. Nix and oxlint are unavailable locally, so just fmt and just typecheck could not run.
The patched release binary also completed the full report against the unchanged local logs. The original trigger was a persisted 226-byte record ending in "type": followed by a newline, with more records after it.
I attempted to open the PR, but GitHub returned GraphQL: bvolpato does not have the correct permissions to execute CreatePullRequest. The signed patch above is ready for review or application by a maintainer.
Steps to reproduce
fixture=$(mktemp -d)
mkdir "$fixture/sessions"
printf '%s' '{"type" :' > "$fixture/sessions/rollout.jsonl"
CODEX_HOME="$fixture" npx [email protected] codex daily --offline --jsonThis synthetic input reproduces the same failure with range start index 10 out of range for slice of length 9 and exit status 134. No private session content is needed.
Expected behavior
Skip malformed records and continue reporting valid usage without panicking.
Version
20.0.45 and 20.0.48 on Linux x86_64. Also reproduced in current main at cde65fb before the patch.
Activity
pullfrog commentedon Nov 6, 2026
github-actions commentedon Nov 6, 2026
Pullfrog triage: priority:high
Kind: bug
Maintenance fit: maintainable
Confidence: high
Confirmed crash: truncated type field makes start exceed line length and the next slice panics, aborting the whole report. Code matches reproducer. Fix is a bounded bounds check preserving core reporting.
Decision: kept open; Pullfrog will attempt a focused implementation PR.
chore: credit issue reporter for #2034