{"record":{"id":"098323d68ee997e3","repo":"nikivdev/code","slug":"session-file-not-found","errorCode":null,"errorMessage":"Session file not found: {}","messagePattern":"Session file not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":1740,"sourceCode":"\n        return Ok((context.trim().to_string(), last_ts));\n    }\n\n    let path_str = project_path.to_string_lossy().to_string();\n    let project_folder = path_to_project_name(&path_str);\n\n    let projects_dir = match provider {\n        Provider::Claude | Provider::All => get_claude_projects_dir(),\n        Provider::Codex => get_codex_projects_dir(),\n        Provider::Cursor => get_cursor_projects_dir(),\n    };\n\n    let session_file = projects_dir\n        .join(&project_folder)\n        .join(format!(\"{}.jsonl\", session_id));\n\n    if !session_file.exists() {\n        bail!(\"Session file not found: {}\", session_file.display());\n    }\n\n    // Collect exchanges after the checkpoint timestamp\n    let mut exchanges: Vec<(String, String, String)> = Vec::new(); // (user_msg, assistant_msg, timestamp)\n    let mut current_user: Option<String> = None;\n    let mut current_ts: Option<String> = None;\n    let mut last_ts: Option<String> = None;\n\n    for_each_nonempty_jsonl_line(&session_file, |line| {\n        if let Ok(entry) = crate::json_parse::parse_json_line::<JsonlEntry>(line) {\n            let entry_ts = entry.timestamp.clone();\n\n            // Skip entries before checkpoint\n            if let (Some(since), Some(ts)) = (since_ts, &entry_ts) {\n                if ts.as_str() <= since {\n                    return;\n                }\n            }","sourceCodeStart":1722,"sourceCodeEnd":1758,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L1722-L1758","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nf restore --session abc123   // typo\n// after\nls ~/.claude/projects/<project-folder>/  # confirm abc124.jsonl exists\nf restore --session abc124","handlingStrategy":"validation","validationCode":"// shell\nSESSION_FILE=\"$HOME/.claude/projects/$(pwd | sed 's|/|-|g')/$SESSION_ID.jsonl\"\n[ -f \"$SESSION_FILE\" ] || { echo \"missing: $SESSION_FILE\"; exit 1; }","typeGuard":"fn session_file_exists(projects_dir: &Path, project_folder: &str, session_id: &str) -> bool {\n    projects_dir.join(project_folder).join(format!(\"{}.jsonl\", session_id)).exists()\n}","tryCatchPattern":"// rust\nmatch restore_checkpoint(...) {\n    Err(e) if e.to_string().starts_with(\"Session file not found\") => {\n        eprintln!(\"Verify the session ID and project directory: {e}\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["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."],"tags":["file-not-found","sessions","claude","checkpoint"],"backgroundTag":"session-file-not-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}