{"record":{"id":"29460f610890e9b6","repo":"BigPizzaV3/CodexPlusPlus","slug":"config-toml-29460f","errorCode":null,"errorMessage":"供应商「{}」缺少独立 config.toml，已停止切换，避免继续显示上一套配置文件。","messagePattern":"供应商「(.+?)」缺少独立 config\\.toml，已停止切换，避免继续显示上一套配置文件。","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/relay_switch.rs","lineNumber":164,"sourceCode":"            &common_config,\n        )?\n    };\n    let status = relay_config_status_from_home(home);\n    if relay.relay_mode == RelayMode::PureApi && !status.configured {\n        anyhow::bail!(\n            \"纯 API 配置写入后未检测到完整 custom provider，请检查 config.toml 和供应商 API Key。\"\n        );\n    }\n    Ok(RelaySwitchResult {\n        settings: settings.clone(),\n        configured: status.configured,\n        backup_path: result.backup_path,\n    })\n}\n\nfn validate_switch_profile_files(profile: &crate::settings::RelayProfile) -> anyhow::Result<()> {\n    if profile.relay_mode != RelayMode::Aggregate && profile.config_contents.trim().is_empty() {\n        anyhow::bail!(\n            \"供应商「{}」缺少独立 config.toml，已停止切换，避免继续显示上一套配置文件。\",\n            if profile.name.trim().is_empty() {\n                profile.id.as_str()\n            } else {\n                profile.name.as_str()\n            }\n        );\n    }\n    if profile.relay_mode == RelayMode::Official\n        && serde_json::from_str::<serde_json::Value>(&profile.auth_contents)\n            .ok()\n            .and_then(|value| {\n                value\n                    .get(\"OPENAI_API_KEY\")\n                    .and_then(serde_json::Value::as_str)\n                    .map(str::trim)\n                    .map(str::is_empty)\n            })","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/relay_switch.rs#L146-L182","documentation":"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).","triggerScenarios":"Calling apply_selected_relay_profile with a RelayProfile whose relay_mode is not Aggregate and whose config_contents field is empty or whitespace-only.","commonSituations":"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.","solutions":["Open the provider profile and paste/save a valid config.toml into config_contents","If the profile is genuinely aggregate-only, set relay_mode to Aggregate so the empty config is allowed","Recreate the profile from the provider's original config file"],"exampleFix":"// before\nRelayProfile { id: \"p1\", name: \"DeepSeek\", relay_mode: RelayMode::Standalone, config_contents: \"\".into(), .. }\n// after\nRelayProfile { id: \"p1\", name: \"DeepSeek\", relay_mode: RelayMode::Standalone, config_contents: std::fs::read_to_string(\"deepseek-config.toml\")?.into(), .. }","handlingStrategy":"validation","validationCode":"fn can_switch(p: &RelayProfile) -> bool {\n    p.relay_mode == RelayMode::Aggregate || !p.config_contents.trim().is_empty()\n}","typeGuard":null,"tryCatchPattern":"match apply_selected_relay_profile(&profile) {\n    Err(e) if e.to_string().contains(\"缺少独立 config.toml\") => prompt_user_for_config(&profile),\n    Err(e) => return Err(e.into()),\n    Ok(r) => r,\n}","preventionTips":["Require a non-empty config textarea before allowing profile save in the UI","Validate profiles at creation/import time, not only at switch time","Render profiles missing config with a visible 'incomplete' badge"],"tags":["config","validation","profile-switching"],"backgroundTag":"empty-required-field","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}