xai-org/grok-build · error
Failed to fetch billing data: {e}
Error message
Failed to fetch billing data: {e} What it means
The billing extension in xai-grok-shell fetches credits/billing data from an upstream HTTP endpoint. If the request itself fails (network error, DNS, TLS), the handler converts the error into an ACP `internal_error` carrying 'Failed to fetch billing data: {e}'. The error text is also reported via telemetry with the upstream error attached as data.
Source
Thrown at crates/codegen/xai-grok-shell/src/extensions/billing.rs:239
.header("x-grok-client-version", xai_grok_version::VERSION)
.header(
crate::http::CLIENT_MODE_HEADER,
crate::http::process_client_mode(),
)
.timeout(std::time::Duration::from_secs(15))
.send()
.await
.map_err(|e| {
tracing::error!(error = %e, "billing: upstream request failed");
xai_grok_telemetry::unified_log::warn(
"billing: upstream request failed",
None,
Some(serde_json::json!({ "error": e.to_string() })),
);
acp::Error::internal_error().data(format!("Failed to fetch billing data: {e}"))
})?;
if !credits_resp.status().is_success() {
let status = credits_resp.status().as_u16();
let body = credits_resp.text().await.unwrap_or_default();
tracing::warn!(status, url = %credits_url, "billing: upstream error");
let detail = serde_json::from_str::<serde_json::Value>(&body)
.ok()
.and_then(|v| v.get("error").and_then(|e| e.as_str()).map(String::from))
.unwrap_or_else(|| format!("HTTP {status}"));
xai_grok_telemetry::unified_log::warn(
"billing: upstream error",
None,
Some(serde_json::json!({
"status": status,
"detail": detail,
})),
);
View on GitHub (pinned to bc7f02eddd)
Solutions
- Check network connectivity/proxy settings for the billing endpoint host; set HTTPS_PROXY if behind a corporate proxy.
- Read `{e}` (also present in the ACP error data) to identify the specific reqwest failure and fix accordingly.
- Verify the configured billing/credits URL in remote settings is correct and reachable (curl it from the same host).
- Retry after transient network issues; if persistent, check status.x.ai or internal service health for the billing service.
Example fix
// before: no proxy configured in an air-gapped env let resp = client.get(credits_url).send().await?; // after: configure proxy/env or fail fast with connectivity check export HTTPS_PROXY=http://proxy.corp:8080 let resp = client.get(credits_url).send().await?;
Defensive patterns
Strategy: retry
Validate before calling
// check the endpoint is reachable before invoking the billing handler
const ok = await fetch(creditsUrl, { method: "HEAD" }).then(r => r.ok).catch(() => false);
if (!ok) console.warn("billing endpoint unreachable; expect Failed to fetch billing data"); Try / catch
try {
const billing = await acp.request("billing_get");
} catch (e) {
if (String(e.message).startsWith("Failed to fetch billing data")) {
await backoffRetry(() => acp.request("billing_get"), 3); // transient network?
} else { throw e; }
} Prevention
- Set HTTPS_PROXY/HTTP_PROXY in restricted networks
- Verify the billing base URL in remote settings is reachable from the host
- Retry with exponential backoff for transient network faults
- Monitor egress/DNS health in CI environments
When it happens
Trigger: `credits_resp` future resolves with `Err(e)` from the HTTP client — connection refused/timeout to the billing endpoint, DNS failure, TLS handshake error, or reqwest client misconfiguration — inside `handle_get_billing`.
Common situations: Offline machine or corporate proxy blocking the billing host; wrong API base URL in remote settings; expired/rotated credentials causing TLS or auth-layer connection resets; firewall in CI preventing egress.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- send failed: {body}
- screen query failed: {body}
- resize failed: {body}
- wait failed: {body}
- stop failed: {body}
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/2fb8496661f12062.
Report an issue: GitHub.