{"record":{"id":"93bf7966d565ecf3","repo":"zed-industries/zed","slug":"admin-user-request-failed","errorCode":null,"errorMessage":"admin user request failed {} - {}","messagePattern":"admin user request failed (.+?) - (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/client/src/client.rs","lineNumber":1594,"sourceCode":"        }\n\n        let url = self\n            .http\n            .build_zed_cloud_url(\"/internal/users/impersonate\")?;\n        let request = Request::post(url.as_str())\n            .header(\"Content-Type\", \"application/json\")\n            .header(\"Authorization\", format!(\"Bearer {api_token}\"))\n            .body(\n                serde_json::to_string(&ImpersonateUserBody {\n                    github_login: login,\n                })?\n                .into(),\n            )?;\n\n        let mut response = http.send(request).await?;\n        let mut body = String::new();\n        response.body_mut().read_to_string(&mut body).await?;\n        anyhow::ensure!(\n            response.status().is_success(),\n            \"admin user request failed {} - {}\",\n            response.status().as_u16(),\n            body,\n        );\n        let response: ImpersonateUserResponse = serde_json::from_str(&body)?;\n\n        Ok(Credentials {\n            user_id: response.user_id,\n            access_token: response.access_token,\n        })\n    }\n\n    pub async fn cached_llm_token(\n        &self,\n        llm_token: &LlmApiToken,\n        organization_id: OrganizationId,\n    ) -> Result<String> {","sourceCodeStart":1576,"sourceCodeEnd":1612,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/client/src/client.rs#L1576-L1612","documentation":"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).","triggerScenarios":"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.","commonSituations":"Staff-only credential impersonation during support/debugging with a rotated or mis-copied token; staging environments where the admin API is not deployed.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let response = http.send(request).await?;\nlet status = response.status();\nif status == StatusCode::UNAUTHORIZED || status == StatusCode::FORBIDDEN {\n    anyhow::bail!(\"admin token rejected ({status}); verify ZED_ADMIN_API_TOKEN and staff role\");\n}\nif !status.is_success() {\n    anyhow::bail!(\"admin user request failed {} - {}\", status.as_u16(), body);\n}","preventionTips":["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"],"tags":["authentication","admin","api","staff"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}