Hmbown/CodeWhale · error
invalid provider_models.
Error message
invalid provider_models.{provider_id} value: {err} What it means
When the /config document is saved, every entry of settings.provider_models (per-provider model overrides) is resolved to a provider identity and run through validate_and_normalize_model (crates/tui/src/config_ui.rs:851). Any validation failure is wrapped with the offending provider_id so the bad override is identifiable; the {err} suffix is the underlying model-validation message.
Solutions
- Read the {err} suffix — it is the model-validation message for that specific provider
- Edit or delete the failing provider_models.<id> entry in /config and save again
- Re-pick each provider's model with /model so the stored ids are current
Example fix
# before [provider_models] openai = "gpt-nonexistent" # after [provider_models] openai = "gpt-4o"
Defensive patterns
Strategy: validation
Validate before calling
for (provider_id, model) in &doc.settings.provider_models {
let identity = config.resolve_provider_identity(provider_id).map_err(anyhow::Error::msg)?;
validate_and_normalize_model(config, identity.provider, model)
.with_context(|| format!("pre-check provider_models.{provider_id}"))?;
} Prevention
- Run the same validate_and_normalize_model loop before enabling Save in /config
- Show per-provider validation errors next to the offending field instead of failing the whole save at the end
- Purge provider_models entries for custom providers that no longer resolve
When it happens
Trigger: Saving /config with provider_models containing a model id that fails validation for its provider, e.g. {"openai": "gpt-typo"} or a custom-gateway model id stored under a built-in provider id.
Common situations: Stale overrides after a provider renames or retires models; overrides copied between machines with different custom endpoints; a provider switch leaving orphaned entries behind.
Related errors
- Could not read legacy route preferences; configuration was…
- could not release root config policy
- custom theme requires custom_theme_name
- Failed to parse boolean
- Failed to update setting: invalid
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/d302ae54767c70b3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/config_ui.rs:851
let document_identity = config
.resolve_provider_identity(&doc.runtime.provider)
.map_err(anyhow::Error::msg)?;
if document_identity.provider != app.api_provider
|| document_identity.key != app.provider_identity_for_persistence()
{
bail!(
"provider changed from '{}' to '{}' while editing; switch providers with /provider, then reopen /config",
app.provider_identity_for_persistence(),
doc.runtime.provider
);
}
validate_and_normalize_model(config, app.api_provider, &doc.runtime.model)?;
for (provider_id, model) in &doc.settings.provider_models {
let identity = config
.resolve_provider_identity(provider_id)
.map_err(anyhow::Error::msg)?;
validate_and_normalize_model(config, identity.provider, model)
.map_err(|err| anyhow::anyhow!("invalid provider_models.{provider_id} value: {err}"))?;
}
if doc.config.mcp_config_path.trim().is_empty() {
bail!("mcp_config_path cannot be empty");
}
let _ = theme_setting_for_document(doc)?;
Ok(())
}
fn theme_setting_for_document(doc: &ConfigUiDocument) -> Result<String> {
let setting = if doc.settings.theme == UiThemeValue::Custom {
let name = doc
.settings
.custom_theme_name
.as_deref()
.map(str::trim)
.filter(|name| !name.is_empty())
.ok_or_else(|| anyhow::anyhow!("custom theme requires custom_theme_name"))?;
format!("{}{}", crate::palette::USER_THEME_PREFIX, name)View on GitHub (pinned to 0c42157ee5)