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).

Source

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

async fn request_models(
    models_url: Arc<str>,
    oauth_token: String,
    client: Arc<dyn HttpClient>,
) -> Result<Vec<Model>> {
    let request_builder = copilot_request_headers(
        HttpRequest::builder()
            .method(Method::GET)
            .uri(models_url.as_ref()),
        &oauth_token,
        None,
        None,
    );

    let request = request_builder.body(AsyncBody::empty())?;

    let mut response = client.send(request).await?;

    anyhow::ensure!(
        response.status().is_success(),
        "Failed to request models: {}",
        response.status()
    );
    let mut body = Vec::new();
    response.body_mut().read_to_end(&mut body).await?;

    let body_str = std::str::from_utf8(&body)?;

    let models = serde_json::from_str::<ModelSchema>(body_str)?.data;

    Ok(models)
}

async fn stream_completion(
    client: Arc<dyn HttpClient>,
    oauth_token: String,
    completion_url: Arc<str>,

View on GitHub (pinned to f4178619ac)

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@f4178619ac (2026-08-20). Data as JSON: /api/errors/8c123e22a47723aa. Report an issue: GitHub.