BigPizzaV3/CodexPlusPlus · error · anyhow::Error

Backup source database not found: {}

Error message

Backup source database not found: {}

What it means

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.

Source

Thrown at crates/codex-plus-data/src/storage.rs:918

                insert_row(db, table, row)?;
            }
        }
    }
    Ok(())
}

fn backup_source_db(
    backup: &Value,
    fallback_db_path: &Path,
    allowed_db_paths: &[PathBuf],
) -> anyhow::Result<PathBuf> {
    let source_db = backup["source_db"]
        .as_str()
        .filter(|path| !path.trim().is_empty())
        .map(PathBuf::from)
        .unwrap_or_else(|| fallback_db_path.to_path_buf());
    if !source_db.is_file() {
        anyhow::bail!(
            "Backup source database not found: {}",
            source_db.to_string_lossy()
        );
    }
    let source_db = fs::canonicalize(source_db)?;
    let allowed = allowed_db_paths
        .iter()
        .filter_map(|path| fs::canonicalize(path).ok())
        .any(|path| path == source_db);
    if !allowed {
        anyhow::bail!("Backup source database is not an allowed local storage path");
    }
    Ok(source_db)
}

fn schema_kind(db: &Connection) -> anyhow::Result<Option<SchemaKind>> {
    if has_table(db, "sessions")? && has_columns(db, "sessions", &["id", "title"])? {
        if has_table(db, "messages")? && !has_columns(db, "messages", &["session_id"])? {

View on GitHub (pinned to f2074595a2)

Solutions

  1. 确认本地会话数据库文件仍在原路径且未被移动或删除
  2. 检查备份 JSON 中 source_db 字段记录的路径
  3. 若数据库被迁移,将其放回或更新备份记录中的路径
  4. 避免在删除后手动搬动 .codex 目录
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-data/src/storage.rs:918 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/86ccf4f76e6140bd. Report an issue: GitHub.