{"record":{"id":"c02af3c252ad6637","repo":"BigPizzaV3/CodexPlusPlus","slug":"unknown-restore-table-table","errorCode":null,"errorMessage":"unknown restore table: {table}","messagePattern":"unknown restore table: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-data/src/storage.rs","lineNumber":1096,"sourceCode":"fn validate_restore_tables(tables: &Map<String, Value>) -> anyhow::Result<()> {\n    let allowed = [\n        \"sessions\",\n        \"messages\",\n        \"threads\",\n        \"thread_dynamic_tools\",\n        \"thread_goals\",\n        \"thread_spawn_edges\",\n        \"stage1_outputs\",\n        \"agent_job_items\",\n        \"automation_runs\",\n        \"inbox_items\",\n        \"__files\",\n        \"__session_index\",\n        \"__sidebar\",\n    ];\n    for table in tables.keys() {\n        if !allowed.contains(&table.as_str()) {\n            anyhow::bail!(\"unknown restore table: {table}\");\n        }\n    }\n    Ok(())\n}\n\nfn detect_restore_conflicts(db: &Connection, tables: &Map<String, Value>) -> anyhow::Result<()> {\n    for (table, rows) in tables {\n        if table.starts_with(\"__\") {\n            continue;\n        }\n        let Some(rows) = rows.as_array() else {\n            continue;\n        };\n        for row in rows {\n            let Some(row) = row.as_object() else {\n                continue;\n            };\n            if restore_row_conflicts(db, table, row)? {","sourceCodeStart":1078,"sourceCodeEnd":1114,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-data/src/storage.rs#L1078-L1114","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove unknown table keys from the backup JSON's tables map (keep only allowlisted tables) and retry.","Use a backup created by the same CodexPlusPlus version; re-export the backup with the current version.","If a legit new table was added upstream, upgrade the library so its allowlist includes it.","Inspect the error message for the offending table name and migrate it into a supported table if applicable."],"exampleFix":"// before\nlet backup: Value = serde_json::from_str(&text)?; // contains \"custom_notes\" table\nstorage.restore_backups(&backup)?;\n// after\nlet mut backup: Value = serde_json::from_str(&text)?;\nif let Some(tables) = backup.get_mut(\"tables\").and_then(|t| t.as_object_mut()) {\n    tables.retain(|name, _| ALLOWED_RESTORE_TABLES.contains(&name.as_str()));\n}\nstorage.restore_backups(&backup)?;","handlingStrategy":"validation","validationCode":"const ALLOWED: &[&str] = &[\"threads\",\"thread_spawn_edges\",\"stage1_outputs\",\"agent_job_items\",\"automation_runs\",\"inbox_items\",\"__files\",\"__session_index\",\"__sidebar\"];\nlet unknown: Vec<&str> = backup[\"tables\"].as_object().map(|t| {\n    t.keys().map(|k| k.as_str()).filter(|k| !ALLOWED.contains(k)).collect()\n}).unwrap_or_default();\nif !unknown.is_empty() { anyhow::bail!(\"backup has unsupported tables: {unknown:?}\"); }","typeGuard":"fn tables_are_known(backup: &Value) -> bool {\n    backup[\"tables\"].as_object()\n        .map(|t| t.keys().all(|k| KNOWN_RESTORE_TABLES.contains(&k.as_str())))\n        .unwrap_or(false)\n}","tryCatchPattern":"match storage.restore_backups(&backup) {\n    Ok(()) => {}\n    Err(e) if e.to_string().starts_with(\"unknown restore table\") => {\n        let table = extract_quoted(&e.to_string());\n        eprintln!(\"dropping unsupported table '{table}' from backup and retrying\");\n        drop_table_from_backup(&mut backup, &table);\n        storage.restore_backups(&backup)?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Create and consume backups with the same library version","Validate backup JSON keys against the allowlist before restoring","Strip third-party or hand-added table keys from backup files","Re-export backups after upgrading if the table set changed"],"tags":["validation","restore","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}