BigPizzaV3/CodexPlusPlus · error

供应商配置总开关已关闭,未写入 config.toml / auth.json。

Error message

供应商配置总开关已关闭,未写入 config.toml / auth.json。

What it means

switch_relay_profile_in_home refuses to switch provider profiles when the backend settings have relay_profiles_enabled = false. The master switch for multi-provider configuration is off, so no config.toml / auth.json writes are performed and the switch aborts.

Solutions

  1. Enable the relay-profiles master switch in settings (set relay_profiles_enabled = true) and retry
  2. Update the caller to check relay_profiles_enabled before invoking the switch
  3. Re-save settings in the manager UI so the flag persists
  4. Inspect settings.json to confirm the flag state before automating switches

Example fix

// before
await invoke("switch_relay_profile", { settings: { relay_profiles_enabled: false, ... } })
// after
if (!settings.relay_profiles_enabled) throw new Error("enable relay profiles first");
await invoke("switch_relay_profile", { settings });
Defensive patterns

Strategy: validation

Validate before calling

if (!settings.relay_profiles_enabled) {
  throw new Error('relay profiles are disabled; enable the master switch before switching providers');
}
await invoke('switch_relay_profile', { settings });

Type guard

const canSwitch = (s) => s.relay_profiles_enabled === true;

Try / catch

try { await switchProfile(settings); } catch (e) { if (String(e).includes('总开关已关闭')) { showEnableRelayProfilesPrompt(); } else throw e; }

Prevention

When it happens

Trigger: Calling switch_relay_profile_in_home (via the manager's switch command) with next_settings.relay_profiles_enabled == false — i.e. the user toggled off the provider-profiles feature (or loaded settings where it defaulted off) and then attempted a profile switch.

Common situations: User disabled the provider-config master toggle in the manager UI and an automation/script still tried to switch; settings.json synced/reset from another machine lost the enabled flag; a fresh install defaults the flag off.

Related errors


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

Appendix: source

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

};
use crate::settings::{BackendSettings, RelayMode, SettingsStore};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RelaySwitchResult {
    pub settings: BackendSettings,
    pub configured: bool,
    pub backup_path: Option<String>,
}

pub fn switch_relay_profile_in_home(
    store: &SettingsStore,
    home: &Path,
    next_settings: BackendSettings,
    previous_active_relay_id: &str,
) -> anyhow::Result<RelaySwitchResult> {
    let mut selected_settings = next_settings;
    if !selected_settings.relay_profiles_enabled {
        anyhow::bail!("供应商配置总开关已关闭,未写入 config.toml / auth.json。");
    }
    crate::codex_app_state::capture_app_state_snapshot_nonfatal(home, "relay_switch.before");

    let original_settings = store.load().unwrap_or_default();
    let live_snapshot = LiveFilesSnapshot::capture(home).context("读取当前 Codex 实时配置失败")?;
    if !previous_active_relay_id.trim().is_empty()
        && previous_active_relay_id != selected_settings.active_relay_id
    {
        backfill_profile_before_switch(home, &mut selected_settings, previous_active_relay_id)?;
    }

    store
        .save(&selected_settings)
        .context("保存供应商设置失败")?;
    let selected_settings = store.load().context("读取供应商设置失败")?;

    match apply_selected_relay_profile(home, &selected_settings) {
        Ok(result) => {

View on GitHub (pinned to b1ed92e5e4)