Hmbown/CodeWhale · error · anyhow::Error

model cannot be empty

Error message

model cannot be empty

What it means

Validation in save_provider_model_for_identity (guided provider setup, comment-preserving config path): the model string to persist as the provider's default was empty or whitespace-only. A default model key must name a real model; an empty value would leave the provider with no usable default, so the write is rejected before touching the config.

Source

Thrown at crates/tui/src/config.rs:11570

            "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 default model for `provider` via the comment-preserving config
/// path used by guided provider setup (#3875). DeepSeek writes root
/// `default_text_model`; other hosted providers write `[providers.<name>] model`.
pub(crate) fn save_provider_model_for_identity(
    identity: &ProviderIdentity,
    _route_config: &Config,
    model: &str,
) -> Result<PathBuf> {
    let provider = identity.provider;
    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.")?;
    ensure_parent_dir(&config_path)?;

    let is_legacy_literal_custom = provider == ApiProvider::Custom
        && identity.key.trim() == ApiProvider::Custom.as_str()
        && identity.persisted_id().is_none();
    if matches!(provider, ApiProvider::Deepseek | ApiProvider::DeepseekCN)
        || is_legacy_literal_custom
    {
        crate::config_persistence::mutate_config_document(&config_path, |doc| {
            crate::config_persistence::set_document_value(doc, &["default_text_model"], model)
        })
        .with_context(|| format!("Failed to write config to {}", config_path.display()))?;
        return Ok(config_path);
    }

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Pass an actual model id (e.g. from the provider's model list)
  2. Fix the guided-setup step that submitted an empty model
  3. Trim user input before calling; whitespace-only counts as empty
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/config.rs:11570 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/836b065195dac1fd. Report an issue: GitHub.