{"record":{"id":"2216e20385b42d0b","repo":"zed-industries/zed","slug":"error-x-ai-subscribed","errorCode":null,"errorMessage":"{error:#}","messagePattern":"\\{error:#\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/language_models/src/provider/x_ai_subscribed.rs","lineNumber":94,"sourceCode":"    fn recommended_models(&self, cx: &App) -> Vec<Arc<dyn LanguageModel>> {\n        self.default_model(cx).into_iter().collect()\n    }\n\n    fn is_authenticated(&self, cx: &App) -> bool {\n        self.state.read(cx).is_authenticated()\n    }\n\n    fn authenticate(&self, cx: &mut App) -> Task<Result<(), AuthenticateError>> {\n        if self.is_authenticated(cx) {\n            return Task::ready(Ok(()));\n        }\n        let load_task: Option<Shared<_>> = self.state.read(cx).load_task();\n        if let Some(load_task) = load_task {\n            let weak_state = self.state.downgrade();\n            cx.spawn(async move |cx| {\n                load_task\n                    .await\n                    .map_err(|error| AuthenticateError::Other(anyhow!(\"{error:#}\")))?;\n                let is_auth = weak_state\n                    .read_with(&*cx, |state, _| state.is_authenticated())\n                    .map_err(AuthenticateError::Other)?;\n                if is_auth {\n                    Ok(())\n                } else {\n                    Err(AuthenticateError::CredentialsNotFound)\n                }\n            })\n        } else {\n            Task::ready(Err(AuthenticateError::CredentialsNotFound))\n        }\n    }\n\n    fn settings_view(&self, cx: &mut App) -> Option<ProviderSettingsView> {\n        let is_authenticated = self.state.read(cx).is_authenticated();\n        let title = if is_authenticated {\n            None","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/language_models/src/provider/x_ai_subscribed.rs#L76-L112","documentation":"x_ai's authenticate() wraps any failure of the pending credentials load_task into AuthenticateError::Other(anyhow!(\"{error:#}\")), and re-wraps state-read failures the same way. The message is opaque on purpose: it is the underlying error (network failure, bad API key, credential-store error) formatted with its full cause chain. Authentication of the xAI provider failed for whatever reason the load task reported.","triggerScenarios":"Calling provider.authenticate() (or instantiating the provider via new()) while a load_task is in flight and that task fails — e.g. reading the stored xAI API key fails, the credentials HTTP request fails, or the read_with on state errors after the task succeeded but the user is not authenticated.","commonSituations":"Missing or revoked xAI API key in the credentials store; no network access when fetching credentials; expired credentials; environment where the keychain/credential helper is unavailable.","solutions":["Read the full formatted cause chain in the message to find the root error (key missing vs network vs store failure).","Re-enter the xAI API key (sign out / sign in for the provider) to refresh stored credentials.","Verify network connectivity to api.x.ai and any proxy configuration.","Ensure the OS credential store is accessible (unlocked keychain, working credential helper).","Retry authentication; transient load-task failures clear on a subsequent call."],"exampleFix":"// before\nmatch provider.authenticate(cx).await {\n    Ok(()) => {},\n    Err(e) => panic!(\"auth failed: {e}\"),\n}\n// after\nmatch provider.authenticate(cx).await {\n    Ok(()) => {},\n    Err(e) => {\n        log::warn!(\"x_ai auth failed: {e:#}; prompting user for API key\");\n        prompt_for_api_key(ProviderId::Xai, cx);\n    }\n}","handlingStrategy":"try-catch","validationCode":"// before authenticating, check a key exists\nlet has_key = cx\n    .read(|cx| credentials::read_provider_option(ProviderId::Xai, cx))\n    .is_some();\nif !has_key { prompt_for_api_key(ProviderId::Xai, cx); }","typeGuard":null,"tryCatchPattern":"match provider.authenticate(cx).await {\n    Ok(()) => proceed(),\n    Err(AuthenticateError::Other(e)) => {\n        log::warn!(\"x_ai auth failed: {e:#}\");\n        prompt_for_api_key(ProviderId::Xai, cx);\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Store a valid xAI API key before constructing the provider","Check network reachability before authentication in offline environments","Surface the full '{error:#}' chain to the user instead of the truncated first line","Handle credential-store unavailability (locked keychain) explicitly"],"tags":["authentication","api-key","http","provider","async"],"backgroundTag":"authentication-required","analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-09-19T19:09:50.599Z","contentChangedAt":"2026-09-19T19:09:50.599Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}