zed-industries/zed · error
No organization selected.
Error message
No organization selected.
What it means
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.
Source
Thrown at crates/client/src/llm_token.rs:111
client,
user_store,
llm_api_token,
_clear_llm_token_on_sign_out: clear_llm_token_on_sign_out,
_subscription: subscription,
}
}
fn refresh(&self, mode: TokenRefreshMode, cx: &mut Context<Self>) {
let client = self.client.clone();
let llm_api_token = self.llm_api_token.clone();
let organization_id = self
.user_store
.read(cx)
.current_organization()
.map(|organization| organization.id.clone());
cx.spawn(async move |this, cx| {
let organization_id =
organization_id.ok_or_else(|| anyhow!("No organization selected."))?;
match mode {
TokenRefreshMode::Refresh => {
client
.refresh_llm_token(&llm_api_token, organization_id)
.await?;
}
TokenRefreshMode::ClearAndRefresh => {
client
.clear_and_refresh_llm_token(&llm_api_token, organization_id)
.await?;
}
}
this.update(cx, |_this, cx| cx.emit(LlmTokenRefreshedEvent))
})
.detach_and_log_err(cx);
}
View on GitHub (pinned to bc538def45)
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
Defensive patterns
Strategy: validation
Validate before calling
// ensure an organization exists before refreshing the LLM token
let organization_id = user_store
.read(cx)
.current_organization()
.map(|organization| organization.id.clone());
let Some(organization_id) = organization_id else {
log::debug!("no organization selected; skipping LLM token refresh");
return;
}; Try / catch
if let Err(err) = llm_token.refresh(mode, cx) {
if err.to_string().contains("No organization selected") {
// benign at startup before org loads; retry after sign-in state settles
cx.notify();
} else {
log::error!("llm token refresh failed: {err:#}");
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Fresh install before completing sign-in; org membership changes server-side; racing an AI action immediately at startup before the user store populated.
Related errors
- authentication canceled
- Failed to parse UNIT_DATA as JSON: ${e.message}
- HTTP error! status: ${response.status}
- Claude returned no tool_use block for tool '{tool['name']}'
- output token limit reached
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/1631ef023a0d14bc.
Report an issue: GitHub.