BigPizzaV3/CodexPlusPlus · error · anyhow::Error

{key} 必须是 TOML table

Error message

{key} 必须是 TOML table

What it means

Generic guard in table_mut_or_insert (relay_config.rs): fired when a key being edited in config.toml (via set_codex_goals_feature_in_home, merge_common_config_into_config or ensure_provider_table) exists as a non-table value, so nested keys cannot be written. The offending input is the scalar/array value under that key in config.toml.

Source

Thrown at crates/codex-plus-core/src/relay_config.rs:165

    if enabled {
        if !updated.is_empty() {
            updated.push_str("\n\n");
        }
        updated.push_str("[features]\ngoals = true");
    }
    ensure_trailing_newline(updated)
}

fn table_mut_or_insert<'a>(doc: &'a mut DocumentMut, key: &str) -> anyhow::Result<&'a mut Table> {
    if !doc.as_table().contains_key(key) {
        doc[key] = toml_edit::table();
    }
    if doc.get(key).and_then(Item::as_table).is_none() {
        doc[key] = toml_edit::table();
    }
    doc.get_mut(key)
        .and_then(Item::as_table_mut)
        .ok_or_else(|| anyhow::anyhow!("{key} 必须是 TOML table"))
}

fn table_mut_if_exists<'a>(doc: &'a mut DocumentMut, key: &str) -> Option<&'a mut Table> {
    doc.get_mut(key).and_then(Item::as_table_mut)
}

pub fn relay_status_from_home(home: &Path) -> RelayStatus {
    let auth = chatgpt_auth_status_from_home(home);
    let config = relay_config_status_from_home(home);
    RelayStatus {
        authenticated: auth.authenticated,
        auth_source: auth.source,
        account_label: auth.account_label,
        config_path: config.config_path,
        configured: config.configured,
        requires_openai_auth: config.requires_openai_auth,
        has_bearer_token: config.has_bearer_token,
    }

View on GitHub (pinned to fb3ebd9a82)

Solutions

  1. Fix config.toml so the key is a proper [table] section
  2. Delete the conflicting scalar and re-apply the relay profile
  3. Regenerate config.toml via Codex++ apply instead of hand-editing
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/relay_config.rs:165 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@fb3ebd9a82 (2026-08-17). Data as JSON: /api/errors/0a7d5cb6271e0994. Report an issue: GitHub.