{"record":{"id":"2eb37e4ffb42e640","repo":"astrid-runtime/astrid","slug":"session-not-found-id","errorCode":null,"errorMessage":"Session not found: {id}","messagePattern":"Session not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/sessions.rs","lineNumber":61,"sourceCode":"        let time = chrono::DateTime::<chrono::Local>::from(modified)\n            .format(\"%Y-%m-%d %H:%M:%S\")\n            .to_string();\n        println!(\"  {} ({})\", Theme::session_id(&id), Theme::dimmed(&time));\n    }\n\n    Ok(())\n}\n\n/// Delete a session by UUID.\npub(crate) fn delete_session(id: &str) -> Result<()> {\n    // Validate as UUID to prevent path traversal (e.g. \"../../config\")\n    uuid::Uuid::parse_str(id)\n        .map_err(|_| anyhow::anyhow!(\"Invalid session ID (must be a UUID): {id}\"))?;\n    let home = AstridHome::resolve().context(\"Failed to resolve Astrid home directory\")?;\n    let session_dir = home.run_dir().join(id);\n\n    if !session_dir.exists() {\n        anyhow::bail!(\"Session not found: {id}\");\n    }\n\n    fs::remove_dir_all(&session_dir)?;\n    println!(\"{}\", Theme::success(&format!(\"Deleted session {id}\")));\n    Ok(())\n}\n\n/// Show information about a session by UUID.\npub(crate) fn session_info(id: &str) -> Result<()> {\n    uuid::Uuid::parse_str(id)\n        .map_err(|_| anyhow::anyhow!(\"Invalid session ID (must be a UUID): {id}\"))?;\n    let home = AstridHome::resolve().context(\"Failed to resolve Astrid home directory\")?;\n    let session_dir = home.run_dir().join(id);\n\n    if !session_dir.exists() {\n        anyhow::bail!(\"Session not found: {id}\");\n    }\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/sessions.rs#L43-L79","documentation":"delete_session validates the ID as a UUID, resolves the Astrid home, and removes the session's directory under run_dir. If no directory with that ID exists, it bails with \"Session not found\" instead of attempting removal. The check prevents silently 'succeeding' on a typo'd or already-deleted session.","triggerScenarios":"`astrid sessions delete <id>` where run_dir/<id> does not exist: the session already ended and was cleaned up, the ID was mistyped, or the session belongs to a different ASTRID_HOME.","commonSituations":"Deleting the same session twice in a script; copying a session ID from another machine; ASTRID_HOME pointing at a different home than the daemon that created the session.","solutions":["List current sessions (`astrid sessions list`) and copy the exact UUID to delete.","If the session already ended, treat the delete as a no-op — the directory is already gone.","Verify ASTRID_HOME points to the home that owned the session before deleting."],"exampleFix":"// before\nastrid sessions delete 9f0c...typo-id\n\n// after\nID=$(astrid sessions list --json | jq -r '.[0].id')\nastrid sessions delete \"$ID\"","handlingStrategy":"validation","validationCode":"let dir = AstridHome::resolve()?.run_dir().join(id);\nif !dir.exists() {\n    eprintln!(\"session {id} is not live; nothing to delete\");\n    return Ok(()); // treat as idempotent no-op\n}","typeGuard":null,"tryCatchPattern":"match delete_session(id) {\n    Err(e) if e.to_string().starts_with(\"Session not found\") => {\n        eprintln!(\"already gone; ignoring\"); // idempotent delete\n    }\n    other => other?,\n}","preventionTips":["Fetch IDs fresh from `astrid sessions list` instead of hardcoding them.","Make delete scripts idempotent by ignoring not-found errors.","Confirm ASTRID_HOME matches the home that owns the session."],"tags":["sessions","not-found","cli","uuid"],"backgroundTag":"record-not-found","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}