BigPizzaV3/CodexPlusPlus · error · anyhow::Error

Unsupported local storage schema

Error message

Unsupported local storage schema

What it means

Thrown by list_local_sessions_limited (surfaces via delete_local and list flows) when the session database exists but its schema_kind is not one the storage layer recognizes (neither CodexThreads nor the legacy shape). The offending input is the SQLite file's schema at db_path — an unknown/foreign database; the layer refuses to guess table layouts and reports the schema as unsupported.

Source

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

                )),
            }
        })();
        result.unwrap_or_else(|err| failed(&session.session_id, err.to_string()))
    }

    pub fn list_local_sessions(&self) -> anyhow::Result<Vec<LocalSession>> {
        self.list_local_sessions_limited(usize::MAX)
    }

    pub fn list_local_sessions_limited(&self, limit: usize) -> anyhow::Result<Vec<LocalSession>> {
        if !self.db_path.exists() {
            return Ok(Vec::new());
        }
        let db = Connection::open(&self.db_path)?;
        match schema_kind(&db)? {
            Some(SchemaKind::CodexThreads) => self.list_codex_threads(&db, limit),
            Some(SchemaKind::CodexAutomationRuns) => self.list_codex_automation_runs(&db, limit),
            _ => anyhow::bail!("Unsupported local storage schema"),
        }
    }

    pub fn list_local_session_ids(&self) -> anyhow::Result<Vec<String>> {
        if !self.db_path.exists() {
            return Ok(Vec::new());
        }
        let db = Connection::open(&self.db_path)?;
        let (table, id_column, filter) = match schema_kind(&db)? {
            Some(SchemaKind::CodexThreads) => ("threads", "id", codex_thread_filter(&db)?),
            Some(SchemaKind::CodexAutomationRuns) => (
                "automation_runs",
                "thread_id",
                "WHERE COALESCE(thread_id, '') <> ''".to_string(),
            ),
            _ => anyhow::bail!("Unsupported local storage schema"),
        };
        let sql = format!("SELECT {id_column} FROM {table} {filter} ORDER BY {id_column}");

View on GitHub (pinned to f2074595a2)

Solutions

  1. 确认 db_path 指向的是本应用或 Codex 生成的会话数据库
  2. 检查数据库文件是否损坏(可用 sqlite3 .schema 检查表结构)
  3. 若为手工构造的测试库,按支持的 schema 建表
  4. 为新 schema 增加 schema_kind 识别与删除支持
Defensive patterns

Strategy: validation

When it happens

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