Skip to content

fix(pi): skip unparseable session lines instead of failing the read#121

Open
akesling wants to merge 1 commit into
mainfrom
fix/pi-tolerate-truncated-lines
Open

fix(pi): skip unparseable session lines instead of failing the read#121
akesling wants to merge 1 commit into
mainfrom
fix/pi-tolerate-truncated-lines

Conversation

@akesling

@akesling akesling commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Root cause

A crash-truncated final line (invalid JSON) in a Pi session JSONL hard-failed the entire session read in read_session_from_file (crates/toolpath-pi/src/reader.rs). The session would still list fine (io.rs is tolerant), but refuse to load. Sibling crate toolpath-codex already documents skip-and-warn as the safe reader policy for exactly this scenario (toolpath-codex/src/reader.rs).

Fix

The non-header entry-parse Err arm now skips the unparseable line with a warning (path, line number, parse error) instead of returning Err — matching both the codex policy and Pi's own existing unknown-entry-type branch style. Header parsing is unchanged: a session without a parseable header still hard-fails (no identity without it).

Tests

Three new tests in reader.rs (TDD; first two red before the fix):

  • truncated final line is skipped, prior entries survive
  • garbage mid-file line is skipped, later entries survive
  • malformed header still hard-fails

Full workspace suite + clippy green. toolpath-pi bumped 0.6.0 → 0.6.1 (crate, workspace dep, crates.json, CHANGELOG, Cargo.lock).

Notes

  • Part of a six-PR consistency series from a cross-harness audit; CHANGELOG/version lines may conflict with sibling fix PRs — resolve by keeping both entries.
  • No path-cli/toolpath-cli bump here; one release bump lands after the series merges.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🔍 Preview deployed: https://ede30cbf.toolpath.pages.dev

akesling added a commit that referenced this pull request Jul 8, 2026
Behavior-adding changes on this branch (pi metadata entries via events;
opencode user model + snapshot-SHA events). The .1 patch numbers are
claimed by sibling PRs #121/#122 currently in flight, so both crates
skip to .2. All five sites updated: crate Cargo.toml, root workspace
dependency, site/_data/crates.json, CHANGELOG top section, Cargo.lock.
No path-cli / toolpath-cli / toolpath-convo bumps.
@@ -220,10 +220,12 @@ pub fn read_session_from_file(path: &Path) -> Result<PiSession> {
continue;
}
Err(_) => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we print the actual error? Also, this reader isn't the right place to make the decision on whether to strictly skip or not, depending on the error. We should probably bubble the set of errors found up to the caller to make a decision as to how to handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant