Hmbown/CodeWhale · error

xAI device-code request failed ({err})

Error message

xAI device-code request failed ({err})

What it means

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.

Source

Thrown at crates/tui/src/xai_oauth.rs:1236

        .build()
        .context("Failed to build xAI device-code client")?;
    let params = [("client_id", client_id), ("scope", scopes)];
    #[cfg(test)]
    crate::external_credentials::record_oauth_network();
    let response = client
        .post(device_authorization_endpoint)
        .form(&params)
        .send()
        .context("xAI device-code request failed")?;
    let (status, body): (_, DeviceCodeResponse) =
        parse_oauth_json_response(response, "xAI device-code request")?;
    if !status.is_success() || body.error.is_some() {
        let err = oauth_failure_detail(
            body.error.as_deref(),
            body.error_description.as_deref(),
            status,
        );
        bail!("xAI device-code request failed ({err})");
    }
    let device_code = body
        .device_code
        .filter(|value| !value.trim().is_empty())
        .context("xAI device-code response missing device_code")?;
    let user_code = body
        .user_code
        .filter(|value| !value.trim().is_empty())
        .context("xAI device-code response missing user_code")?;
    Ok(DeviceCodeGrant {
        device_code,
        user_code,
        verification_uri: body.verification_uri,
        verification_uri_complete: body.verification_uri_complete,
        expires_in: body.expires_in,
        interval: body.interval,
    })
}

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Verify network connectivity and DNS resolution for the xAI device authorization endpoint
  2. Check for proxies or firewalls blocking the endpoint; configure or bypass them
  3. Retry the device-code login after transient network issues clear
  4. Use XAI_API_KEY authentication if the OAuth endpoints remain unreachable
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/tui/src/xai_oauth.rs:1236 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/f746cbbcdf4a45e4. Report an issue: GitHub.