{"record":{"id":"b02fc5feda0a3701","repo":"Hmbown/CodeWhale","slug":"operation-returned-http-status-with-content-ty","errorCode":null,"errorMessage":"{operation} returned HTTP {status} with content type {content_type}; expected JSON{limit}","messagePattern":"(.+?) returned HTTP (.+?) with content type (.+?); expected JSON(.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/xai_oauth.rs","lineNumber":1123,"sourceCode":"        .unwrap_or(\"missing\")\n        .to_string();\n    let mut reader = response.take(OAUTH_RESPONSE_BODY_LIMIT + 1);\n    let mut body = Vec::new();\n    reader\n        .read_to_end(&mut body)\n        .with_context(|| format!(\"reading {operation} response\"))?;\n    let truncated = body.len() as u64 > OAUTH_RESPONSE_BODY_LIMIT;\n    if truncated {\n        body.truncate(OAUTH_RESPONSE_BODY_LIMIT as usize);\n    }\n\n    let parsed = serde_json::from_slice(&body).map_err(|_| {\n        let limit = if truncated {\n            \" (body exceeded the 64 KiB diagnostic limit)\"\n        } else {\n            \"\"\n        };\n        anyhow::anyhow!(\n            \"{operation} returned HTTP {status} with content type {content_type}; expected JSON{limit}\"\n        )\n    })?;\n    Ok((status, parsed))\n}\n\nfn oauth_failure_detail(\n    error: Option<&str>,\n    description: Option<&str>,\n    status: reqwest::StatusCode,\n) -> String {\n    let mut code = bounded_oauth_error_text(error.unwrap_or(\"request_failed\"));\n    if code.is_empty() {\n        code = \"request_failed\".to_string();\n    }\n    let description = description\n        .map(bounded_oauth_error_text)\n        .filter(|description| !description.is_empty() && description != &code);","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/xai_oauth.rs#L1105-L1141","documentation":"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.","triggerScenarios":"Thrown at crates/tui/src/xai_oauth.rs:1123 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"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-14T00:17:10.932Z"}