zed-industries/zed · error

Failed to request models

Error message

Failed to request models: {}

What it means

In request_models for Copilot Chat: anyhow::ensure! fires when the HTTP response from the Copilot models endpoint has a non-success status. It surfaces the status code so callers know the provider rejected the models listing request (auth expiry, server error, rate limit).

Solutions

  1. Check the status: 401/403 means the OAuth token expired — re-sign-in; 5xx is a Copilot service issue
  2. Retry the request after re-authentication or service recovery
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/copilot_chat/src/copilot_chat.rs:1026 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20). Data as JSON: /api/errors/8c123e22a47723aa. Report an issue: GitHub.

Appendix: source

Thrown at crates/copilot_chat/src/copilot_chat.rs:1034

        .data
        .context("GraphQL response contained no data field")?;

    Ok(data.viewer.copilot_endpoints.api)
}

pub(crate) fn copilot_request_headers(
    builder: http_client::Builder,
    oauth_token: &str,
    is_user_initiated: Option<bool>,
    location: Option<ChatLocation>,
) -> http_client::Builder {
    builder
        .header("Authorization", format!("Bearer {}", oauth_token))
        .header("Content-Type", "application/json")
        .header(
            "Editor-Version",
            format!(
                "Zed/{}",
                option_env!("CARGO_PKG_VERSION").unwrap_or("unknown")
            ),
        )
        .header("X-GitHub-Api-Version", "2025-10-01")
        .when_some(is_user_initiated, |builder, is_user_initiated| {
            builder.header(
                "X-Initiator",
                if is_user_initiated { "user" } else { "agent" },
            )
        })
        .when_some(location, |builder, loc| {
            let interaction_type = loc.to_intent_string();
            builder
                .header("X-Interaction-Type", interaction_type)
                .header("OpenAI-Intent", interaction_type)
        })
}

View on GitHub (pinned to 916fc2b8cb)