Hmbown/CodeWhale · error
model cannot be empty
Error message
model cannot be empty
What it means
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.
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
Example fix
// before save_provider_model_for_identity(&identity, &cfg, " ")?; // after let model = input.trim(); anyhow::ensure!(!model.is_empty(), "model required"); save_provider_model_for_identity(&identity, &cfg, model)?;
Defensive patterns
Strategy: validation
Validate before calling
let model = model.trim();
if model.is_empty() { return Err(anyhow::anyhow!("model required")); } Try / catch
if let Err(e) = save_provider_model_for_identity(&identity, &cfg, m) {
if e.to_string().contains("model cannot be empty") {
// fall back to the provider's default model
}
} Prevention
- 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
When it happens
Trigger: Calling `save_provider_model_for_identity` with `model` that is empty or whitespace-only after trim.
Common situations: TUI model picker submitted with no selection; script passed an unset variable; a provider listing failed and returned an empty model string.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- base URL cannot be empty
- browser URL cannot be empty
- Choose both a provider and a model.
- classifier-approved read command was empty
- Codewhale runtime event file is empty.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/836b065195dac1fd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/config.rs:12701
"backend": "config_file",
"provider": identity.key,
"config_path": config_path.display().to_string(),
}),
);
codewhale_config::scrub_plaintext_api_keys_from_config_backup(&config_path)?;
Ok(SavedCredential::ConfigFile(config_path))
}
/// Persist a guided-setup model through the same canonical route writer used
/// by Runtime and the interactive model picker.
pub(crate) fn save_provider_model_for_identity(
identity: &ProviderIdentity,
_route_config: &Config,
model: &str,
) -> Result<PathBuf> {
let model = model.trim();
anyhow::ensure!(!model.is_empty(), "model cannot be empty");
let config_path =
try_default_config_path().context("Failed to resolve config path for provider model.")?;
crate::config_persistence::persist_provider_model_key(
Some(&config_path),
identity.provider,
identity.persisted_id().unwrap_or(&identity.key),
model,
)
}
/// Persist a guided-setup endpoint choice into the provider's own
/// `[providers.<name>] base_url` (#4526).
///
/// Deliberately narrow: it never touches the root `base_url`, another
/// provider's table, or any other key, so a billing-route choice cannot
/// repoint an unrelated route.
pub(crate) fn save_provider_base_url_for_identity(
identity: &ProviderIdentity,View on GitHub (pinned to 73e0f67d83)