BigPizzaV3/CodexPlusPlus · error · anyhow::Error

restore conflict: file already exists: {path}

Error message

restore conflict: file already exists: {path}

What it means

Thrown by detect_file_restore_conflicts when an allowed backup file path already exists on disk — the rollback would overwrite a live rollout file. Mirrors the row-conflict policy (never clobber current data); the offending input is the existing file at {path}, and the undo aborts before writing any file.

Source

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

            .map(|(key, _)| vec![key])
            .unwrap_or_default()
    } else {
        keys
    }
}

fn detect_file_restore_conflicts(tables: &Map<String, Value>) -> anyhow::Result<()> {
    let Some(files) = tables.get("__files").and_then(Value::as_array) else {
        return Ok(());
    };
    let allowed_paths = allowed_backup_file_paths(tables);
    for file in files {
        if let Some(path) = file.get("path").and_then(Value::as_str) {
            if !allowed_paths.contains(path) {
                anyhow::bail!("unexpected backup file path: {path}");
            }
            if Path::new(path).exists() {
                anyhow::bail!("restore conflict: file already exists: {path}");
            }
            if let Some(content) = file.get("content_b64").and_then(Value::as_str) {
                base64::Engine::decode(&base64::engine::general_purpose::STANDARD, content)?;
            }
        }
    }
    Ok(())
}

fn allowed_backup_file_paths(tables: &Map<String, Value>) -> HashSet<String> {
    tables
        .get("threads")
        .and_then(Value::as_array)
        .into_iter()
        .flatten()
        .filter_map(|row| row.get("rollout_path").and_then(Value::as_str))
        .filter(|path| !path.trim().is_empty())
        .map(ToString::to_string)

View on GitHub (pinned to f2074595a2)

Solutions

  1. 确认是否在重复执行 undo(文件已恢复过一次)
  2. 先手动备份并移除冲突的现存文件再重试恢复
  3. 若现存文件是较新的会话数据,评估是否真的需要覆盖式恢复
  4. 在 UI 明确提示冲突文件路径供用户决策
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-data/src/storage.rs:1101 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/0715b324e3c537f2. Report an issue: GitHub.