BigPizzaV3/CodexPlusPlus · error · anyhow::Error

unexpected backup file path: {path}

Error message

unexpected backup file path: {path}

What it means

Thrown by detect_file_restore_conflicts when a __files entry's path is not among the allowed backup file paths derived from the same backup. This confines file restores to the thread-rollouts locations the backup legitimately references; the offending input is the {path} field inside the backup's __files array (a traversal or foreign-path attempt).

Source

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

        .collect::<Vec<_>>();
    if table == "messages" && keys.is_empty() {
        row.get_key_value("session_id")
            .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()

View on GitHub (pinned to f2074595a2)

Solutions

  1. 确认备份文件未被篡改、其 __files 路径与 rollouts 记录一致
  2. 使用本应用生成的原始 undo token
  3. 为新类型的文件输出补充 allowed_backup_file_paths 推导规则
  4. 从备份中移除越界文件条目后重试
Defensive patterns

Strategy: validation

When it happens

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