{"record":{"id":"1631ef023a0d14bc","repo":"zed-industries/zed","slug":"no-organization-selected","errorCode":null,"errorMessage":"No organization selected.","messagePattern":"No organization selected\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/client/src/llm_token.rs","lineNumber":111,"sourceCode":"            client,\n            user_store,\n            llm_api_token,\n            _clear_llm_token_on_sign_out: clear_llm_token_on_sign_out,\n            _subscription: subscription,\n        }\n    }\n\n    fn refresh(&self, mode: TokenRefreshMode, cx: &mut Context<Self>) {\n        let client = self.client.clone();\n        let llm_api_token = self.llm_api_token.clone();\n        let organization_id = self\n            .user_store\n            .read(cx)\n            .current_organization()\n            .map(|organization| organization.id.clone());\n        cx.spawn(async move |this, cx| {\n            let organization_id =\n                organization_id.ok_or_else(|| anyhow!(\"No organization selected.\"))?;\n\n            match mode {\n                TokenRefreshMode::Refresh => {\n                    client\n                        .refresh_llm_token(&llm_api_token, organization_id)\n                        .await?;\n                }\n                TokenRefreshMode::ClearAndRefresh => {\n                    client\n                        .clear_and_refresh_llm_token(&llm_api_token, organization_id)\n                        .await?;\n                }\n            }\n            this.update(cx, |_this, cx| cx.emit(LlmTokenRefreshedEvent))\n        })\n        .detach_and_log_err(cx);\n    }\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/client/src/llm_token.rs#L93-L129","documentation":"Refreshing the LLM API token requires an organization id, read from the user store's current_organization(). This error fires when no organization is selected/loaded at refresh time, so there is nothing to scope the token refresh to.","triggerScenarios":"TokenRefreshMode::Refresh or ClearAndRefresh runs while current_organization() returns None: the user is signed out, organization data has not loaded yet after startup, or the account belongs to no organization.","commonSituations":"Fresh install before completing sign-in; org membership changes server-side; racing an AI action immediately at startup before the user store populated.","solutions":["Sign in and make sure your account has an organization selected","Retry after sign-in/organization data has loaded (a few seconds after startup)","If your account has no organization, create or join one before using Zed AI features"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure an organization exists before refreshing the LLM token\nlet organization_id = user_store\n    .read(cx)\n    .current_organization()\n    .map(|organization| organization.id.clone());\nlet Some(organization_id) = organization_id else {\n    log::debug!(\"no organization selected; skipping LLM token refresh\");\n    return;\n};","typeGuard":null,"tryCatchPattern":"if let Err(err) = llm_token.refresh(mode, cx) {\n    if err.to_string().contains(\"No organization selected\") {\n        // benign at startup before org loads; retry after sign-in state settles\n        cx.notify();\n    } else {\n        log::error!(\"llm token refresh failed: {err:#}\");\n    }\n}","preventionTips":["Gate AI-feature calls on a selected organization in UI state","Re-run token refresh once the user store emits an organization update","Treat this as a soft skip at startup, not a hard failure"],"tags":["llm","organization","client","sign-in"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}