{"record":{"id":"836b065195dac1fd","repo":"Hmbown/CodeWhale","slug":"model-cannot-be-empty-836b06","errorCode":null,"errorMessage":"model cannot be empty","messagePattern":"model cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":12701,"sourceCode":"            \"backend\": \"config_file\",\n            \"provider\": identity.key,\n            \"config_path\": config_path.display().to_string(),\n        }),\n    );\n    codewhale_config::scrub_plaintext_api_keys_from_config_backup(&config_path)?;\n\n    Ok(SavedCredential::ConfigFile(config_path))\n}\n\n/// Persist a guided-setup model through the same canonical route writer used\n/// by Runtime and the interactive model picker.\npub(crate) fn save_provider_model_for_identity(\n    identity: &ProviderIdentity,\n    _route_config: &Config,\n    model: &str,\n) -> Result<PathBuf> {\n    let model = model.trim();\n    anyhow::ensure!(!model.is_empty(), \"model cannot be empty\");\n    let config_path =\n        try_default_config_path().context(\"Failed to resolve config path for provider model.\")?;\n    crate::config_persistence::persist_provider_model_key(\n        Some(&config_path),\n        identity.provider,\n        identity.persisted_id().unwrap_or(&identity.key),\n        model,\n    )\n}\n\n/// Persist a guided-setup endpoint choice into the provider's own\n/// `[providers.<name>] base_url` (#4526).\n///\n/// Deliberately narrow: it never touches the root `base_url`, another\n/// provider's table, or any other key, so a billing-route choice cannot\n/// repoint an unrelated route.\npub(crate) fn save_provider_base_url_for_identity(\n    identity: &ProviderIdentity,","sourceCodeStart":12683,"sourceCodeEnd":12719,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L12683-L12719","documentation":"Argument guard in save_provider_model_for_identity: after trimming, the model string is empty, so there is no model to persist through the canonical route writer. The guided-setup model was rejected before any route/config file is written.","triggerScenarios":"Calling `save_provider_model_for_identity` with `model` that is empty or whitespace-only after trim.","commonSituations":"TUI model picker submitted with no selection; script passed an unset variable; a provider listing failed and returned an empty model string.","solutions":["Pass a valid non-empty model identifier to the save routine","Trim and validate the model string in the caller","Default to a known-good model for the provider before saving"],"exampleFix":"// before\nsave_provider_model_for_identity(&identity, &cfg, \" \")?;\n// after\nlet model = input.trim();\nanyhow::ensure!(!model.is_empty(), \"model required\");\nsave_provider_model_for_identity(&identity, &cfg, model)?;","handlingStrategy":"validation","validationCode":"let model = model.trim();\nif model.is_empty() { return Err(anyhow::anyhow!(\"model required\")); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = save_provider_model_for_identity(&identity, &cfg, m) {\n    if e.to_string().contains(\"model cannot be empty\") {\n        // fall back to the provider's default model\n    }\n}","preventionTips":["Require a model selection in the UI before enabling save","Default to the provider's known-good model when none chosen","Trim model strings coming from lists or scripts"],"tags":["validation","model","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}