{"record":{"id":"cf628ef1691450df","repo":"zed-industries/zed","slug":"copilot-sign-in-failed-other","errorCode":null,"errorMessage":"Copilot sign-in failed: {other}","messagePattern":"Copilot sign-in failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/copilot_chat/src/copilot_oauth.rs","lineNumber":134,"sourceCode":"\n        let mut response = client.send(request).await?;\n        let mut response_body = Vec::new();\n        response.body_mut().read_to_end(&mut response_body).await?;\n\n        let parsed: AccessTokenResponse = serde_json::from_slice(&response_body)\n            .context(\"Failed to parse GitHub access-token response\")?;\n\n        if let Some(token) = parsed.access_token {\n            return Ok(token);\n        }\n\n        match parsed.error.as_deref() {\n            Some(\"authorization_pending\") => continue,\n            // GitHub asks us to back off; increase the interval and keep polling.\n            Some(\"slow_down\") => interval += 5,\n            Some(\"expired_token\") => bail!(\"The Copilot sign-in code expired. Please try again.\"),\n            Some(\"access_denied\") => bail!(\"Copilot sign-in was cancelled.\"),\n            Some(other) => bail!(\"Copilot sign-in failed: {other}\"),\n            None => bail!(\"Copilot sign-in failed: unexpected response from GitHub\"),\n        }\n    }\n}\n\nfn form_encode(fields: &[(&str, &str)]) -> String {\n    fields\n        .iter()\n        .map(|(key, value)| format!(\"{}={}\", url_encode(key), url_encode(value)))\n        .collect::<Vec<_>>()\n        .join(\"&\")\n}\n\nfn url_encode(value: &str) -> String {\n    let mut encoded = String::with_capacity(value.len());\n    for byte in value.bytes() {\n        match byte {\n            b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/copilot_chat/src/copilot_oauth.rs#L116-L152","documentation":"Catch-all for device-flow error codes GitHub returns that are not authorization_pending, slow_down, expired_token, or access_denied. The literal error code from GitHub is interpolated into 'Copilot sign-in failed: {other}'. These come from RFC-compatible device-authorization endpoints (e.g. incorrect_device_code, incorrect_client_credentials, unsupported_grant_type).","triggerScenarios":"The token poll receives an unrecognized error code: polling after the device code was superseded by a new flow (incorrect_device_code), client credentials mismatch (incorrect_client_credentials), or the endpoint semantics changed (unsupported_grant_type / unsupported_token_type).","commonSituations":"Two sign-in attempts racing (each new device code invalidates the old one); clock skew or long pauses between polls; GitHub changing device-flow error semantics; malformed intermediate proxies altering responses.","solutions":["Note the embedded error code; for incorrect_device_code, restart the flow and abandon the old code","Ensure only one sign-in flow is active per client at a time","For credential/grant errors, update Zed so the client_id/grant it sends matches GitHub's current requirements","Retry sign-in from scratch"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Serialize flows: one device code at a time\nstatic FLOW_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());\nlet _guard = FLOW_LOCK.lock().unwrap_or_else(|p| p.into_inner());","typeGuard":null,"tryCatchPattern":"match poll_for_token(/* .. */).await {\n    Ok(token) => Ok(token),\n    Err(err) => {\n        let msg = err.to_string();\n        if msg.contains(\"incorrect_device_code\") { /* restart flow */ }\n        else { Err(err.context(\"unexpected device-flow error\")) }\n    }\n}","preventionTips":["Never run two device flows concurrently - a new code invalidates the old","Log the raw error code from GitHub; it is the only precise signal in this catch-all"],"tags":["copilot","oauth","device-flow","github","rust"],"backgroundTag":"oauth-device-flow-error","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}