nikivdev/code · error
Session file not found: {}
Error message
Session file not found: {} What it means
This error is thrown when constructing a Claude session file path (`<claude projects dir>/<project_folder>/<session_id>.jsonl`) for a checkpoint/rollback operation and the file does not exist on disk. The library bails before reading exchanges because there is no session history to rewind.
Source
Thrown at src/ai.rs:1740
return Ok((context.trim().to_string(), last_ts));
}
let path_str = project_path.to_string_lossy().to_string();
let project_folder = path_to_project_name(&path_str);
let projects_dir = match provider {
Provider::Claude | Provider::All => get_claude_projects_dir(),
Provider::Codex => get_codex_projects_dir(),
Provider::Cursor => get_cursor_projects_dir(),
};
let session_file = projects_dir
.join(&project_folder)
.join(format!("{}.jsonl", session_id));
if !session_file.exists() {
bail!("Session file not found: {}", session_file.display());
}
// Collect exchanges after the checkpoint timestamp
let mut exchanges: Vec<(String, String, String)> = Vec::new(); // (user_msg, assistant_msg, timestamp)
let mut current_user: Option<String> = None;
let mut current_ts: Option<String> = None;
let mut last_ts: Option<String> = None;
for_each_nonempty_jsonl_line(&session_file, |line| {
if let Ok(entry) = crate::json_parse::parse_json_line::<JsonlEntry>(line) {
let entry_ts = entry.timestamp.clone();
// Skip entries before checkpoint
if let (Some(since), Some(ts)) = (since_ts, &entry_ts) {
if ts.as_str() <= since {
return;
}
}View on GitHub (pinned to a747e741ae)
Solutions
- Verify the session ID is correct and the .jsonl file exists under the Claude projects directory.
- Recompute the project folder from the correct working directory (path_to_project_name depends on it).
- List available sessions in ~/.config (or equivalent) claude projects dir to find the right ID.
- Re-create the session if the file was pruned; checkpoints for it are unrecoverable.
Example fix
// before f restore --session abc123 // typo // after ls ~/.claude/projects/<project-folder>/ # confirm abc124.jsonl exists f restore --session abc124
Defensive patterns
Strategy: validation
Validate before calling
// shell
SESSION_FILE="$HOME/.claude/projects/$(pwd | sed 's|/|-|g')/$SESSION_ID.jsonl"
[ -f "$SESSION_FILE" ] || { echo "missing: $SESSION_FILE"; exit 1; } Type guard
fn session_file_exists(projects_dir: &Path, project_folder: &str, session_id: &str) -> bool {
projects_dir.join(project_folder).join(format!("{}.jsonl", session_id)).exists()
} Try / catch
// rust
match restore_checkpoint(...) {
Err(e) if e.to_string().starts_with("Session file not found") => {
eprintln!("Verify the session ID and project directory: {e}");
}
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- List existing .jsonl session files before referencing a session ID.
- Run restore/summary commands from the original project directory.
- Back up session files before Claude prunes old ones.
When it happens
Trigger: Calling the checkpoint-restore path with a session_id whose `<projects-dir>/<project-folder>/<session_id>.jsonl` file is missing — e.g. a deleted, pruned, or mistyped session ID, or a project folder name mismatch.
Common situations: Restoring an old checkpoint after Claude cleaned up old sessions; typos in the session ID; running from a different working directory so the project folder resolves differently.
Related errors
- Could not find agent file for '{}'
- open/resolve is only supported for Codex sessions; use `f co
- No exchanges found in session
- Session file not found for Codex session {}
- Session file not found for Cursor session {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/098323d68ee997e3.
Report an issue: GitHub.