{"record":{"id":"b28908dade2f48f2","repo":"zed-industries/zed","slug":"oauth-token-is-missing-while-updating-copilot-chat","errorCode":null,"errorMessage":"OAuth token is missing while updating Copilot Chat models","messagePattern":"OAuth token is missing while updating Copilot Chat models","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/copilot_chat/src/copilot_chat.rs","lineNumber":723,"sourceCode":"            credentials_provider\n                .delete_credentials(COPILOT_AGENT_CREDENTIALS_URL, cx)\n                .await\n                .context(\"deleting Copilot agent credentials from the keychain\")?;\n            anyhow::Ok(())\n        })\n    }\n\n    async fn update_models(this: &WeakEntity<Self>, cx: &mut AsyncApp) -> Result<()> {\n        let (oauth_token, client, configuration) = this.read_with(cx, |this, _| {\n            (\n                this.oauth_token.clone(),\n                this.client.clone(),\n                this.configuration.clone(),\n            )\n        })?;\n\n        let oauth_token = oauth_token\n            .ok_or_else(|| anyhow!(\"OAuth token is missing while updating Copilot Chat models\"))?;\n\n        let api_endpoint =\n            Self::resolve_api_endpoint(&this, &oauth_token, &configuration, &client, cx).await?;\n\n        let models_url = configuration.models_url(&api_endpoint);\n        let models = get_models(models_url.into(), oauth_token, client.clone()).await?;\n\n        this.update(cx, |this, cx| {\n            this.models = Some(models);\n            cx.notify();\n        })?;\n        anyhow::Ok(())\n    }\n\n    pub fn is_authenticated(&self) -> bool {\n        self.oauth_token.is_some()\n    }\n","sourceCodeStart":705,"sourceCodeEnd":741,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/copilot_chat/src/copilot_chat.rs#L705-L741","documentation":"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.","triggerScenarios":"Thrown at crates/copilot_chat/src/copilot_chat.rs:723 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Sign in to Copilot Chat so an OAuth token is stored","Retry the model refresh after authentication completes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}