Hmbown/CodeWhale · error · anyhow::Error
{operation} returned HTTP {status} with content type {conten
Error message
{operation} returned HTTP {status} with content type {content_type}; expected JSON{limit} What it means
OAuth token endpoint returned an HTTP success response whose body is not valid JSON — the body was truncated to a diagnostic limit (noting when the original exceeded 64 KiB) and included in the error with the response's content type, so a misbehaving or unexpected server response can be diagnosed.
Source
Thrown at crates/tui/src/xai_oauth.rs:1123
.unwrap_or("missing")
.to_string();
let mut reader = response.take(OAUTH_RESPONSE_BODY_LIMIT + 1);
let mut body = Vec::new();
reader
.read_to_end(&mut body)
.with_context(|| format!("reading {operation} response"))?;
let truncated = body.len() as u64 > OAUTH_RESPONSE_BODY_LIMIT;
if truncated {
body.truncate(OAUTH_RESPONSE_BODY_LIMIT as usize);
}
let parsed = serde_json::from_slice(&body).map_err(|_| {
let limit = if truncated {
" (body exceeded the 64 KiB diagnostic limit)"
} else {
""
};
anyhow::anyhow!(
"{operation} returned HTTP {status} with content type {content_type}; expected JSON{limit}"
)
})?;
Ok((status, parsed))
}
fn oauth_failure_detail(
error: Option<&str>,
description: Option<&str>,
status: reqwest::StatusCode,
) -> String {
let mut code = bounded_oauth_error_text(error.unwrap_or("request_failed"));
if code.is_empty() {
code = "request_failed".to_string();
}
let description = description
.map(bounded_oauth_error_text)
.filter(|description| !description.is_empty() && description != &code);View on GitHub (pinned to 0c42157ee5)
Solutions
- Retry the OAuth operation; transient proxy or gateway responses often resolve on retry.
- Inspect the recorded status, content type, and body snippet to identify the intercepting server (proxy, captive portal, misconfigured endpoint).
- Verify the configured xAI OAuth endpoint URLs point at the genuine API host.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/tui/src/xai_oauth.rs:1123 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/b02fc5feda0a3701.
Report an issue: GitHub.