{"record":{"id":"f746cbbcdf4a45e4","repo":"Hmbown/CodeWhale","slug":"xai-device-code-request-failed-err","errorCode":null,"errorMessage":"xAI device-code request failed ({err})","messagePattern":"xAI device-code request failed \\((.+?)\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/xai_oauth.rs","lineNumber":1236,"sourceCode":"        .build()\n        .context(\"Failed to build xAI device-code client\")?;\n    let params = [(\"client_id\", client_id), (\"scope\", scopes)];\n    #[cfg(test)]\n    crate::external_credentials::record_oauth_network();\n    let response = client\n        .post(device_authorization_endpoint)\n        .form(&params)\n        .send()\n        .context(\"xAI device-code request failed\")?;\n    let (status, body): (_, DeviceCodeResponse) =\n        parse_oauth_json_response(response, \"xAI device-code request\")?;\n    if !status.is_success() || body.error.is_some() {\n        let err = oauth_failure_detail(\n            body.error.as_deref(),\n            body.error_description.as_deref(),\n            status,\n        );\n        bail!(\"xAI device-code request failed ({err})\");\n    }\n    let device_code = body\n        .device_code\n        .filter(|value| !value.trim().is_empty())\n        .context(\"xAI device-code response missing device_code\")?;\n    let user_code = body\n        .user_code\n        .filter(|value| !value.trim().is_empty())\n        .context(\"xAI device-code response missing user_code\")?;\n    Ok(DeviceCodeGrant {\n        device_code,\n        user_code,\n        verification_uri: body.verification_uri,\n        verification_uri_complete: body.verification_uri_complete,\n        expires_in: body.expires_in,\n        interval: body.interval,\n    })\n}","sourceCodeStart":1218,"sourceCodeEnd":1254,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/xai_oauth.rs#L1218-L1254","documentation":"The POST to the xAI device-authorization endpoint failed at the transport layer (connection refused, TLS error, timeout, DNS failure) before any HTTP response arrived. This is a network-level failure of the first step of device-code login, distinct from an HTTP error response, which would surface through oauth_failure_detail instead.","triggerScenarios":"Thrown at crates/tui/src/xai_oauth.rs:1236 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify network connectivity and DNS resolution for the xAI device authorization endpoint","Check for proxies or firewalls blocking the endpoint; configure or bypass them","Retry the device-code login after transient network issues clear","Use XAI_API_KEY authentication if the OAuth endpoints remain unreachable"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}