zed-industries/zed · error
admin user request failed {} - {}
Error message
admin user request failed {} - {} What it means
The admin impersonation flow POSTs a GitHub login to the admin API with a bearer token and requires a 2xx response. On any other status it fails, including the numeric status and the response body, which usually states the reason (invalid token, not staff, user unknown).
Source
Thrown at crates/client/src/client.rs:1594
}
let url = self
.http
.build_zed_cloud_url("/internal/users/impersonate")?;
let request = Request::post(url.as_str())
.header("Content-Type", "application/json")
.header("Authorization", format!("Bearer {api_token}"))
.body(
serde_json::to_string(&ImpersonateUserBody {
github_login: login,
})?
.into(),
)?;
let mut response = http.send(request).await?;
let mut body = String::new();
response.body_mut().read_to_string(&mut body).await?;
anyhow::ensure!(
response.status().is_success(),
"admin user request failed {} - {}",
response.status().as_u16(),
body,
);
let response: ImpersonateUserResponse = serde_json::from_str(&body)?;
Ok(Credentials {
user_id: response.user_id,
access_token: response.access_token,
})
}
pub async fn cached_llm_token(
&self,
llm_token: &LlmApiToken,
organization_id: OrganizationId,
) -> Result<String> {View on GitHub (pinned to bc538def45)
Solutions
- Read the response body in the error message — it distinguishes auth failure from server error
- Verify the admin API token value and ensure it belongs to a staff account
- Confirm the GitHub login maps to an existing Zed user
- If the status is 5xx, retry later or check server health
Defensive patterns
Strategy: try-catch
Try / catch
let response = http.send(request).await?;
let status = response.status();
if status == StatusCode::UNAUTHORIZED || status == StatusCode::FORBIDDEN {
anyhow::bail!("admin token rejected ({status}); verify ZED_ADMIN_API_TOKEN and staff role");
}
if !status.is_success() {
anyhow::bail!("admin user request failed {} - {}", status.as_u16(), body);
} Prevention
- Distinguish 401/403 (credential problem) from 5xx (server problem) in handling
- Rotate admin tokens on a schedule and update dependent environments together
- Never log the token itself while debugging this endpoint
When it happens
Trigger: ZED_ADMIN_API_TOKEN is invalid/expired, the token's account lacks admin rights, the given GitHub login does not map to a user, or the admin endpoint returns 5xx.
Common situations: Staff-only credential impersonation during support/debugging with a rotated or mis-copied token; staging environments where the admin API is not deployed.
Related errors
- Sentry API returned HTTP {error.code} for {path}: {detail}
- Sentry API returned HTTP {err.code} for {path}: {detail}
- Anthropic does not support custom tool calls
- authentication canceled
- connection timed out
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/93bf7966d565ecf3.
Report an issue: GitHub.