BigPizzaV3/CodexPlusPlus · error

供应商「 」缺少独立 config.toml,已停止切换,避免继续显示上一套配置文件。

Error message

供应商「{}」缺少独立 config.toml,已停止切换,避免继续显示上一套配置文件。

What it means

apply_selected_relay_profile refuses to switch to a relay profile whose independent config.toml content is empty (unless it's an Aggregate-mode profile). Switching with empty config would leave the previous provider's config.toml in place, showing stale settings. The error names the offending profile (name, or id if unnamed).

Solutions

  1. Open the provider profile and paste/save a valid config.toml into config_contents
  2. If the profile is genuinely aggregate-only, set relay_mode to Aggregate so the empty config is allowed
  3. Recreate the profile from the provider's original config file

Example fix

// before
RelayProfile { id: "p1", name: "DeepSeek", relay_mode: RelayMode::Standalone, config_contents: "".into(), .. }
// after
RelayProfile { id: "p1", name: "DeepSeek", relay_mode: RelayMode::Standalone, config_contents: std::fs::read_to_string("deepseek-config.toml")?.into(), .. }
Defensive patterns

Strategy: validation

Validate before calling

fn can_switch(p: &RelayProfile) -> bool {
    p.relay_mode == RelayMode::Aggregate || !p.config_contents.trim().is_empty()
}

Try / catch

match apply_selected_relay_profile(&profile) {
    Err(e) if e.to_string().contains("缺少独立 config.toml") => prompt_user_for_config(&profile),
    Err(e) => return Err(e.into()),
    Ok(r) => r,
}

Prevention

When it happens

Trigger: Calling apply_selected_relay_profile with a RelayProfile whose relay_mode is not Aggregate and whose config_contents field is empty or whitespace-only.

Common situations: A provider was created in the manager UI without pasting its config.toml; a profile was imported/cloned but the config text was lost; a migration or DB edit blanked config_contents.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/codex-plus-core/src/relay_switch.rs:164

            &common_config,
        )?
    };
    let status = relay_config_status_from_home(home);
    if relay.relay_mode == RelayMode::PureApi && !status.configured {
        anyhow::bail!(
            "纯 API 配置写入后未检测到完整 custom provider,请检查 config.toml 和供应商 API Key。"
        );
    }
    Ok(RelaySwitchResult {
        settings: settings.clone(),
        configured: status.configured,
        backup_path: result.backup_path,
    })
}

fn validate_switch_profile_files(profile: &crate::settings::RelayProfile) -> anyhow::Result<()> {
    if profile.relay_mode != RelayMode::Aggregate && profile.config_contents.trim().is_empty() {
        anyhow::bail!(
            "供应商「{}」缺少独立 config.toml,已停止切换,避免继续显示上一套配置文件。",
            if profile.name.trim().is_empty() {
                profile.id.as_str()
            } else {
                profile.name.as_str()
            }
        );
    }
    if profile.relay_mode == RelayMode::Official
        && serde_json::from_str::<serde_json::Value>(&profile.auth_contents)
            .ok()
            .and_then(|value| {
                value
                    .get("OPENAI_API_KEY")
                    .and_then(serde_json::Value::as_str)
                    .map(str::trim)
                    .map(str::is_empty)
            })

View on GitHub (pinned to b1ed92e5e4)