{"record":{"id":"0795436bf4955f3b","repo":"sigoden/aichat","slug":"err-msg-079543","errorCode":null,"errorMessage":"{err_msg}","messagePattern":"\\{err_msg\\}","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/config/mod.rs","lineNumber":2218,"sourceCode":"\n    fn load_from_file(config_path: &Path) -> Result<Self> {\n        let err = || format!(\"Failed to load config at '{}'\", config_path.display());\n        let content = read_to_string(config_path).with_context(err)?;\n        let config: Self = serde_yaml::from_str(&content)\n            .map_err(|err| {\n                let err_msg = err.to_string();\n                let err_msg = if err_msg.starts_with(&format!(\"{CLIENTS_FIELD}: \")) {\n                    // location is incorrect, get rid of it\n                    err_msg\n                        .split_once(\" at line\")\n                        .map(|(v, _)| {\n                            format!(\"{v} (Sorry for being unable to provide an exact location)\")\n                        })\n                        .unwrap_or_else(|| \"clients: invalid value\".into())\n                } else {\n                    err_msg\n                };\n                anyhow!(\"{err_msg}\")\n            })\n            .with_context(err)?;\n\n        Ok(config)\n    }\n\n    fn load_dynamic(model_id: &str) -> Result<Self> {\n        let provider = match model_id.split_once(':') {\n            Some((v, _)) => v,\n            _ => model_id,\n        };\n        let is_openai_compatible = OPENAI_COMPATIBLE_PROVIDERS\n            .into_iter()\n            .any(|(name, _)| provider == name);\n        let client = if is_openai_compatible {\n            json!({ \"type\": \"openai-compatible\", \"name\": provider })\n        } else {\n            json!({ \"type\": provider })","sourceCodeStart":2200,"sourceCodeEnd":2236,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/config/mod.rs#L2200-L2236","documentation":"In src/config/mod.rs config-loading code, a per-client (or section) configuration value failed validation; the message is dynamic (`{err_msg}`), optionally augmented with the offending value and a note that an exact location cannot be pinpointed. The error is re-thrown via `anyhow!` and layered with context naming the failing field.","triggerScenarios":"Deserializing/validating a config file where a `clients` entry (or similar section) has an invalid value; the raw parse error is converted into `err_msg` and, when the value can't be located, appended with \"(Sorry for being unable to provide an exact location)\".","commonSituations":"Hand-edited config.yaml with a wrong type or unknown enum for a client field; copied config from another tool version; schema drift after upgrading the CLI.","solutions":["Read the full error chain (context) to find which config section failed.","Fix the offending client entry's value/type in the config file.","Compare against the documented config schema for your version after an upgrade.","Temporarily simplify the config to bisect which entry is invalid."],"exampleFix":"// before (config.yaml)\nclients:\n  - type: openai\n    api_key: 12345   # wrong type\n\n// after\nclients:\n  - type: openai\n    api_key: \"sk-...\"","handlingStrategy":"validation","validationCode":"// Pre-validate config parses before use\nserde_yaml::from_str::<Config>(&std::fs::read_to_string(\"config.yaml\")?)\n    .map_err(|e| eprintln!(\"config invalid: {e}\"));","typeGuard":null,"tryCatchPattern":"// Rust\nmatch load_config() {\n    Err(e) => {\n    for cause in e.chain() { eprintln!(\"caused by: {cause}\"); }\n    }\n    Ok(c) => c,\n}","preventionTips":["Keep config files version-controlled and schema-checked.","Re-check client entries after CLI upgrades (schema drift).","Use quoted strings for keys/tokens to avoid type coercion.","Read the whole anyhow error chain, not just the top message."],"tags":["config","validation","yaml"],"backgroundTag":"schema-validation-failed","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}