zed-industries/zed · error

OAuth token is missing while updating Copilot Chat models

Error message

OAuth token is missing while updating Copilot Chat models

What it means

update_models reads the Copilot Chat entity state to obtain its OAuth token; the token was None, so the models list cannot be refreshed. It means Copilot Chat isn't authenticated (or credentials were cleared) at the time of the refresh.

Source

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

            credentials_provider
                .delete_credentials(COPILOT_AGENT_CREDENTIALS_URL, cx)
                .await
                .context("deleting Copilot agent credentials from the keychain")?;
            anyhow::Ok(())
        })
    }

    async fn update_models(this: &WeakEntity<Self>, cx: &mut AsyncApp) -> Result<()> {
        let (oauth_token, client, configuration) = this.read_with(cx, |this, _| {
            (
                this.oauth_token.clone(),
                this.client.clone(),
                this.configuration.clone(),
            )
        })?;

        let oauth_token = oauth_token
            .ok_or_else(|| anyhow!("OAuth token is missing while updating Copilot Chat models"))?;

        let api_endpoint =
            Self::resolve_api_endpoint(&this, &oauth_token, &configuration, &client, cx).await?;

        let models_url = configuration.models_url(&api_endpoint);
        let models = get_models(models_url.into(), oauth_token, client.clone()).await?;

        this.update(cx, |this, cx| {
            this.models = Some(models);
            cx.notify();
        })?;
        anyhow::Ok(())
    }

    pub fn is_authenticated(&self) -> bool {
        self.oauth_token.is_some()
    }

View on GitHub (pinned to f4178619ac)

Solutions

  1. Sign in to Copilot Chat so an OAuth token is stored
  2. Retry the model refresh after authentication completes
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/copilot_chat/src/copilot_chat.rs:723 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/b28908dade2f48f2. Report an issue: GitHub.