BigPizzaV3/CodexPlusPlus · error · anyhow::Error
纯 API 配置写入后未检测到完整 custom provider,请检查 config.toml 和供应商 API K
Error message
纯 API 配置写入后未检测到完整 custom provider,请检查 config.toml 和供应商 API Key。
What it means
apply_selected_relay_profile 在 PureApi 模式写入完成后,用 relay_config_status_from_home 复核:configured 要求 config.toml 有 model_provider 根键、对应 provider 有非空 base_url、且有 experimental_bearer_token 或 auth.json 里存在 API key。三项任缺即 configured=false,PureApi 模式下随即 bail 本错误。注意此时文件已写入,外层 switch 会尝试用切换前快照回滚。
Source
Thrown at crates/codex-plus-core/src/relay_switch.rs:156
let auth_contents =
(!relay.auth_contents.trim().is_empty()).then_some(relay.auth_contents.as_str());
crate::relay_config::clear_relay_config_to_home_with_auth_and_computer_use_guard(
home,
auth_contents,
settings.computer_use_guard_enabled,
)?
} else {
validate_switch_profile_files(&relay)?;
crate::relay_config::apply_relay_profile_to_home_with_switch_rules_and_computer_use_guard(
home,
&relay,
&common_config,
settings.computer_use_guard_enabled,
)?
};
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()View on GitHub (pinned to 1f431ae49b)
Solutions
- 确认 PureApi profile 的 base_url 与 API Key 均非空
- 打开(备份中的)config.toml 检查 model_provider 根键与对应 [model_providers.*] 是否含 base_url
- 修好 profile 后重新执行切换,让写入-复核流程重跑
Example fix
# before (profile config template 缺字段) [model_providers.my] name = "my" # after model_provider = "my" [model_providers.my] name = "my" base_url = "https://api.example.com/v1"
Defensive patterns
Strategy: validation
Validate before calling
fn pure_api_profile_looks_complete(profile: &RelayProfile) -> bool {
!relay_profile_base_url(profile).trim().is_empty()
&& !relay_profile_api_key(profile).trim().is_empty()
&& profile.config_contents.contains("base_url")
&& profile.config_contents.contains("model_provider")
}
anyhow::ensure!(pure_api_profile_looks_complete(&profile), "纯 API 配置不完整");
// 之后再执行切换 Try / catch
match switch_relay_profile_in_home(&store, &home, next, &prev) {
Ok(r) => Ok(r),
Err(err) if err.to_string().contains("未检测到完整 custom provider") => {
// 外层已回滚实时文件;补全 profile 的 base_url / key 后再重试
Err(err)
}
Err(err) => Err(err),
} Prevention
- PureApi profile 保存时校验 base_url、API Key 与 config 模板三要素
- config 模板必须包含 model_provider 根键和 provider 的 base_url
- 理解 configured 判定:provider 需有 bearer token 或 auth.json 有 key
When it happens
Trigger: PureApi profile 的 config_contents 模板缺 base_url / model_provider 键,或 api_key 为空导致 auth.json 无 OPENAI_API_KEY 且 provider 无 bearer token,写入后复核不通过。
Common situations: PureApi profile 只填了 key 没生成完整 config 模板;手写 config.toml 漏掉 [model_providers.x] 的 base_url;profile 数据迁移后字段丢失。
Related errors
- 供应商配置总开关已关闭,未写入 config.toml / auth.json。
- 切换供应商失败:{error};同时回滚配置失败:settings.json={},Codex 实时文件={}
- 供应商「{}」缺少独立 config.toml,已停止切换,避免继续显示上一套配置文件。
- 官方混合 API 不应在 auth.json 中保存 OPENAI_API_KEY。请清理此供应商的 auth.json
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@1f431ae49b (2026-08-16).
Data as JSON: /api/errors/6b2f1088ecac12ff.
Report an issue: GitHub.