BigPizzaV3/CodexPlusPlus · error

unexpected backup file path

Error message

unexpected backup file path: {path}

What it means

During backup restore, detect_file_restore_conflicts validates every entry in the backup's __files array against allowed_backup_file_paths, which is built solely from the rollout_path column of the threads rows in the same backup. If a file entry's path is not one of those rollout_path values, the restore is aborted before anything is written. This guards against restoring files to arbitrary filesystem locations from a tampered or hand-edited backup.

Solutions

  1. Inspect the backup JSON and ensure every __files[].path matches a threads row's rollout_path exactly (string-equal, same separators, no trailing whitespace).
  2. Re-export a fresh backup instead of hand-editing the JSON.
  3. If rollout_path rows are legitimately absent, remove the orphaned __files entries from the backup.
  4. If this is a trusted internal backup format change, update allowed_backup_file_paths/backup generation together so both sides agree.

Example fix

// before: hand-edited backup where __files path diverges from threads.rollout_path
{"__files":[{"path":"/home/u/.codex/sessions/rollout-2026.jsonl"}],"threads":[]}
// after: regenerate the backup so __files derives from threads
{"__files":[{"path":"/home/u/.codex/sessions/rollout-2026.jsonl"}],"threads":[{"rollout_path":"/home/u/.codex/sessions/rollout-2026.jsonl",...}]}
Defensive patterns

Strategy: validation

Validate before calling

const paths: Set<string> = new Set(backup.threads.map(t => t.rollout_path).filter(p => p && p.trim() !== ''));
if (backup.__files?.some(f => !paths.has(f.path))) throw new Error('backup contains file paths not covered by threads.rollout_path');

Type guard

function isAllowedFilePath(backup: Backup, path: string): boolean {
  return backup.threads.some(t => t.rollout_path === path);
}

Prevention

When it happens

Trigger: Calling restore_backups with a backup whose __files array contains a path that does not exactly match any threads.rollout_path in the backup JSON — e.g. the backup was hand-edited, a rollout_path row was dropped from the threads table, or the path string differs in case/whitespace/absolute-vs-relative form.

Common situations: Manually merging or editing backup JSON files; restoring a backup produced by a different/older tool version that wrote file paths in a different format; cross-machine restores where rollout_path values were rewritten but the __files entries were not; a truncated threads array in a corrupted backup.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/0197b0d1b6674217. Report an issue: GitHub.

Appendix: source

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

        .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 b1ed92e5e4)