{"record":{"id":"86ccf4f76e6140bd","repo":"BigPizzaV3/CodexPlusPlus","slug":"backup-source-database-not-found","errorCode":null,"errorMessage":"Backup source database not found: {}","messagePattern":"Backup source database not found: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-data/src/storage.rs","lineNumber":918,"sourceCode":"                insert_row(db, table, row)?;\n            }\n        }\n    }\n    Ok(())\n}\n\nfn backup_source_db(\n    backup: &Value,\n    fallback_db_path: &Path,\n    allowed_db_paths: &[PathBuf],\n) -> anyhow::Result<PathBuf> {\n    let source_db = backup[\"source_db\"]\n        .as_str()\n        .filter(|path| !path.trim().is_empty())\n        .map(PathBuf::from)\n        .unwrap_or_else(|| fallback_db_path.to_path_buf());\n    if !source_db.is_file() {\n        anyhow::bail!(\n            \"Backup source database not found: {}\",\n            source_db.to_string_lossy()\n        );\n    }\n    let source_db = fs::canonicalize(source_db)?;\n    let allowed = allowed_db_paths\n        .iter()\n        .filter_map(|path| fs::canonicalize(path).ok())\n        .any(|path| path == source_db);\n    if !allowed {\n        anyhow::bail!(\"Backup source database is not an allowed local storage path\");\n    }\n    Ok(source_db)\n}\n\nfn schema_kind(db: &Connection) -> anyhow::Result<Option<SchemaKind>> {\n    if has_table(db, \"sessions\")? && has_columns(db, \"sessions\", &[\"id\", \"title\"])? {\n        if has_table(db, \"messages\")? && !has_columns(db, \"messages\", &[\"session_id\"])? {","sourceCodeStart":900,"sourceCodeEnd":936,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/f2074595a281bc057525c748175c8eb9805b0673/crates/codex-plus-data/src/storage.rs#L900-L936","documentation":"Thrown by backup_source_db during undo/restore when the backup record's source_db path (or the fallback db path) does not exist as a file at restore time. The offending input is the backup JSON's source_db/fallback path — the database the rows came from has moved or been deleted since the backup.","triggerScenarios":"Thrown at crates/codex-plus-data/src/storage.rs:918 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["确认本地会话数据库文件仍在原路径且未被移动或删除","检查备份 JSON 中 source_db 字段记录的路径","若数据库被迁移，将其放回或更新备份记录中的路径","避免在删除后手动搬动 .codex 目录"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f2074595a281bc057525c748175c8eb9805b0673","analyzedAt":"2026-08-23T12:52:24.489Z","contentChangedAt":"2026-08-23T12:52:24.489Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}