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

  1. Read the response body in the error message — it distinguishes auth failure from server error
  2. Verify the admin API token value and ensure it belongs to a staff account
  3. Confirm the GitHub login maps to an existing Zed user
  4. 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

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


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/93bf7966d565ecf3. Report an issue: GitHub.