BigPizzaV3/CodexPlusPlus · error · anyhow::Error

Codex 会话数据库缺少必要字段

Error message

Codex 会话数据库缺少必要字段

What it means

Thrown by register_imported_thread (called from import_rollout) when the Codex session database the importer writes to lacks fields required by the INSERT statement — i.e. the on-disk schema is older or newer than expected. The offending input is the local Codex sessions SQLite schema, not the share payload; the thread row cannot be registered against an incompatible schema.

Source

Thrown at crates/codex-plus-core/src/session_share.rs:349

    add!("source", source.to_string());
    add!("model_provider", model_provider.to_string());
    add!("cwd", cwd);
    add!("title", title.to_string());
    add!("sandbox_policy", r#"{"type":"disabled"}"#.to_string());
    add!("approval_mode", "never".to_string());
    add!("tokens_used", 0_i64);
    add!("has_user_event", 1_i64);
    add!("archived", 0_i64);
    add!("cli_version", cli_version.to_string());
    add!("first_user_message", first_message.clone());
    add!("thread_source", thread_source.to_string());
    add!("preview", first_message);
    add!("history_mode", history_mode.to_string());
    add!("recency_at", timestamp);
    add!("recency_at_ms", timestamp.saturating_mul(1000));

    if !columns.contains("id") || !columns.contains("rollout_path") {
        bail!("Codex 会话数据库缺少必要字段");
    }
    let names = values.iter().map(|(name, _)| *name).collect::<Vec<_>>();
    let placeholders = (1..=names.len())
        .map(|index| format!("?{index}"))
        .collect::<Vec<_>>();
    let sql = format!(
        "INSERT OR REPLACE INTO threads ({}) VALUES ({})",
        names.join(", "),
        placeholders.join(", ")
    );
    let params = values
        .iter()
        .map(|(_, value)| value.as_ref())
        .collect::<Vec<_>>();
    db.execute(&sql, rusqlite::params_from_iter(params))?;
    Ok(())
}

View on GitHub (pinned to f2074595a2)

Solutions

  1. 升级 Codex++ 与本机 Codex CLI 版本使数据库 schema 匹配
  2. 检查 sessions.db 是否被降级或损坏,必要时备份后重建
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/session_share.rs:349 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/abde4da6e6941457. Report an issue: GitHub.