{"record":{"id":"74f3e17f0047a504","repo":"zed-industries/zed","slug":"github-device-code-request-failed","errorCode":null,"errorMessage":"GitHub device-code request failed: {}","messagePattern":"GitHub device-code request failed: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/copilot_chat/src/copilot_oauth.rs","lineNumber":73,"sourceCode":"/// Begins a device-code authorization by requesting a user code from GitHub.\npub async fn request_device_code(\n    client: &Arc<dyn HttpClient>,\n    configuration: &CopilotChatConfiguration,\n) -> Result<DeviceFlow> {\n    let body = form_encode(&[\n        (\"client_id\", GITHUB_COPILOT_CLIENT_ID),\n        (\"scope\", DEVICE_CODE_SCOPE),\n    ]);\n\n    let request = HttpRequest::builder()\n        .method(Method::POST)\n        .uri(configuration.device_code_url())\n        .header(\"Accept\", \"application/json\")\n        .header(\"Content-Type\", \"application/x-www-form-urlencoded\")\n        .body(AsyncBody::from(body))?;\n\n    let mut response = client.send(request).await?;\n    anyhow::ensure!(\n        response.status().is_success(),\n        \"GitHub device-code request failed: {}\",\n        response.status()\n    );\n\n    let mut body = Vec::new();\n    response.body_mut().read_to_end(&mut body).await?;\n    let parsed: DeviceCodeResponse =\n        serde_json::from_slice(&body).context(\"Failed to parse GitHub device-code response\")?;\n\n    Ok(DeviceFlow {\n        user_code: parsed.user_code,\n        verification_uri: parsed.verification_uri,\n        device_code: parsed.device_code,\n        interval: parsed.interval.max(1),\n    })\n}\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/copilot_chat/src/copilot_oauth.rs#L55-L91","documentation":"request_device_code POSTs client_id and scope to GitHub's device-code endpoint to begin Copilot Chat sign-in; this error wraps a non-success response, meaning GitHub refused to issue a device code (the message includes the status).","triggerScenarios":"Thrown at crates/copilot_chat/src/copilot_oauth.rs:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check GitHub's status and network connectivity","Inspect the returned status/body for scope or client_id issues","Retry the sign-in attempt after the cause is resolved"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}