BigPizzaV3/CodexPlusPlus · error

unknown restore table

Error message

unknown restore table: {table}

What it means

validate_restore_tables rejects restore payloads containing tables outside the fixed allowlist of known codex data tables (threads, sessions-related, thread_spawn_edges, stage1_outputs, agent_job_items, automation_runs, inbox_items, and the reserved __files/__session_index/__sidebar keys). Unknown table names in the backup JSON make restore fail rather than write to unvalidated tables.

Solutions

  1. Remove unknown table keys from the backup JSON's tables map (keep only allowlisted tables) and retry.
  2. Use a backup created by the same CodexPlusPlus version; re-export the backup with the current version.
  3. If a legit new table was added upstream, upgrade the library so its allowlist includes it.
  4. Inspect the error message for the offending table name and migrate it into a supported table if applicable.

Example fix

// before
let backup: Value = serde_json::from_str(&text)?; // contains "custom_notes" table
storage.restore_backups(&backup)?;
// after
let mut backup: Value = serde_json::from_str(&text)?;
if let Some(tables) = backup.get_mut("tables").and_then(|t| t.as_object_mut()) {
    tables.retain(|name, _| ALLOWED_RESTORE_TABLES.contains(&name.as_str()));
}
storage.restore_backups(&backup)?;
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED: &[&str] = &["threads","thread_spawn_edges","stage1_outputs","agent_job_items","automation_runs","inbox_items","__files","__session_index","__sidebar"];
let unknown: Vec<&str> = backup["tables"].as_object().map(|t| {
    t.keys().map(|k| k.as_str()).filter(|k| !ALLOWED.contains(k)).collect()
}).unwrap_or_default();
if !unknown.is_empty() { anyhow::bail!("backup has unsupported tables: {unknown:?}"); }

Type guard

fn tables_are_known(backup: &Value) -> bool {
    backup["tables"].as_object()
        .map(|t| t.keys().all(|k| KNOWN_RESTORE_TABLES.contains(&k.as_str())))
        .unwrap_or(false)
}

Try / catch

match storage.restore_backups(&backup) {
    Ok(()) => {}
    Err(e) if e.to_string().starts_with("unknown restore table") => {
        let table = extract_quoted(&e.to_string());
        eprintln!("dropping unsupported table '{table}' from backup and retrying");
        drop_table_from_backup(&mut backup, &table);
        storage.restore_backups(&backup)?;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling restore_backups with a backup JSON whose "tables" map contains a key not in the allowlist — e.g. backups from a newer/older schema version that added or renamed tables, or hand-crafted/edited backup files.

Common situations: Restoring a backup produced by a different CodexPlusPlus version whose table set differs; manual editing of backup JSON; third-party tooling exporting extra tables into the backup format.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

fn validate_restore_tables(tables: &Map<String, Value>) -> anyhow::Result<()> {
    let allowed = [
        "sessions",
        "messages",
        "threads",
        "thread_dynamic_tools",
        "thread_goals",
        "thread_spawn_edges",
        "stage1_outputs",
        "agent_job_items",
        "automation_runs",
        "inbox_items",
        "__files",
        "__session_index",
        "__sidebar",
    ];
    for table in tables.keys() {
        if !allowed.contains(&table.as_str()) {
            anyhow::bail!("unknown restore table: {table}");
        }
    }
    Ok(())
}

fn detect_restore_conflicts(db: &Connection, tables: &Map<String, Value>) -> anyhow::Result<()> {
    for (table, rows) in tables {
        if table.starts_with("__") {
            continue;
        }
        let Some(rows) = rows.as_array() else {
            continue;
        };
        for row in rows {
            let Some(row) = row.as_object() else {
                continue;
            };
            if restore_row_conflicts(db, table, row)? {

View on GitHub (pinned to b1ed92e5e4)