zed-industries/zed · error

invalid model id

Error message

invalid model id {id}

What it means

`DeepSeekModel::from_id` parses a model id string from configuration or API responses into the enum. Only the listed ids ('deepseek-flash', 'deepseek-v4-pro') are recognized; anything else returns an `anyhow` error 'invalid model id {id}'. This validates user/model configuration before requests are made.

Solutions

  1. Set the model id in settings to exactly 'deepseek-flash' or 'deepseek-v4-pro'.
  2. Check the provider's available-models list (or `DeepSeekModel::id()` values) and update the configuration.
  3. If a new DeepSeek model exists, add a match arm for it in `from_id` (and `id`).

Example fix

// before (settings.json)
"model": "deepseek-chat"
// after
"model": "deepseek-v4-pro"
Defensive patterns

Strategy: validation

Validate before calling

// validate before calling from_id
const DEEPSEEK_MODELS: &[&str] = &["deepseek-flash", "deepseek-v4-pro"];
if !DEEPSEEK_MODELS.contains(&model_id) {
    return Err(anyhow!("unknown DeepSeek model: {model_id}"));
}
let model = DeepSeekModel::from_id(model_id)?;

Type guard

fn is_valid_deepseek_id(id: &str) -> bool {
    matches!(id, "deepseek-flash" | "deepseek-v4-pro")
}

Try / catch

match DeepSeekModel::from_id(&id) {
    Ok(m) => m,
    Err(e) => { log::error!("{e:#}"); return default_model(); }
}

Prevention

When it happens

Trigger: Calling `DeepSeekModel::from_id` with a model id that isn't in the match list — e.g. a mistyped id in settings, an id from a newer/older DeepSeek API, or a custom deployment name.

Common situations: Typo in the `model` field of DeepSeek provider settings; DeepSeek releasing/renaming models so stored ids no longer match; copying an OpenAI-style id into DeepSeek settings.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-09-19). Data as JSON: /api/errors/bbe380013053ce8a. Report an issue: GitHub.

Appendix: source

Thrown at crates/deepseek/src/deepseek.rs:77

    Custom {
        name: String,
        /// The name displayed in the UI, such as in the agent panel model dropdown menu.
        display_name: Option<String>,
        max_tokens: u64,
        max_output_tokens: Option<u64>,
    },
}

impl Model {
    pub fn default_fast() -> Self {
        Model::V4_1Flash
    }

    pub fn from_id(id: &str) -> Result<Self> {
        match id {
            "deepseek-flash" => Ok(Self::V4_1Flash),
            "deepseek-v4-pro" => Ok(Self::V4Pro),
            _ => anyhow::bail!("invalid model id {id}"),
        }
    }

    pub fn id(&self) -> &str {
        match self {
            Self::V4_1Flash => "deepseek-flash",
            Self::V4Pro => "deepseek-v4-pro",
            Self::Custom { name, .. } => name,
        }
    }

    pub fn display_name(&self) -> &str {
        match self {
            Self::V4_1Flash => "DeepSeek V4.1 Flash",
            Self::V4Pro => "DeepSeek V4 Pro",
            Self::Custom {
                name, display_name, ..
            } => display_name.as_ref().unwrap_or(name).as_str(),

View on GitHub (pinned to 916fc2b8cb)