{"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":731,"sourceCode":"        self.models = None;\n        self.sign_in_task = None;\n        self.status = CopilotChatStatus::SignedOut;\n        cx.notify();\n\n        cx.spawn(async move |_, cx| {\n            credentials_provider\n                .delete_credentials(&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(())","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/copilot_chat/src/copilot_chat.rs#L713-L749","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":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}