{"record":{"id":"d302ae54767c70b3","repo":"Hmbown/CodeWhale","slug":"invalid-provider-models-provider-id-value-err","errorCode":null,"errorMessage":"invalid provider_models.{provider_id} value: {err}","messagePattern":"invalid provider_models\\.(.+?) value: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config_ui.rs","lineNumber":851,"sourceCode":"    let document_identity = config\n        .resolve_provider_identity(&doc.runtime.provider)\n        .map_err(anyhow::Error::msg)?;\n    if document_identity.provider != app.api_provider\n        || document_identity.key != app.provider_identity_for_persistence()\n    {\n        bail!(\n            \"provider changed from '{}' to '{}' while editing; switch providers with /provider, then reopen /config\",\n            app.provider_identity_for_persistence(),\n            doc.runtime.provider\n        );\n    }\n    validate_and_normalize_model(config, app.api_provider, &doc.runtime.model)?;\n    for (provider_id, model) in &doc.settings.provider_models {\n        let identity = config\n            .resolve_provider_identity(provider_id)\n            .map_err(anyhow::Error::msg)?;\n        validate_and_normalize_model(config, identity.provider, model)\n            .map_err(|err| anyhow::anyhow!(\"invalid provider_models.{provider_id} value: {err}\"))?;\n    }\n    if doc.config.mcp_config_path.trim().is_empty() {\n        bail!(\"mcp_config_path cannot be empty\");\n    }\n    let _ = theme_setting_for_document(doc)?;\n    Ok(())\n}\n\nfn theme_setting_for_document(doc: &ConfigUiDocument) -> Result<String> {\n    let setting = if doc.settings.theme == UiThemeValue::Custom {\n        let name = doc\n            .settings\n            .custom_theme_name\n            .as_deref()\n            .map(str::trim)\n            .filter(|name| !name.is_empty())\n            .ok_or_else(|| anyhow::anyhow!(\"custom theme requires custom_theme_name\"))?;\n        format!(\"{}{}\", crate::palette::USER_THEME_PREFIX, name)","sourceCodeStart":833,"sourceCodeEnd":869,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/config_ui.rs#L833-L869","documentation":"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.","triggerScenarios":"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.","commonSituations":"Stale overrides after a provider renames or retires models; overrides copied between machines with different custom endpoints; a provider switch leaving orphaned entries behind.","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"],"exampleFix":"# before\n[provider_models]\nopenai = \"gpt-nonexistent\"\n\n# after\n[provider_models]\nopenai = \"gpt-4o\"","handlingStrategy":"validation","validationCode":"for (provider_id, model) in &doc.settings.provider_models {\n    let identity = config.resolve_provider_identity(provider_id).map_err(anyhow::Error::msg)?;\n    validate_and_normalize_model(config, identity.provider, model)\n        .with_context(|| format!(\"pre-check provider_models.{provider_id}\"))?;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["config-ui","provider-models","model-validation","settings"],"backgroundTag":"model-validation-failed","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}