{"record":{"id":"297b4492fc8a0336","repo":"tinyhumansai/openhuman","slug":"failed-to-parse-mcp-json-response-e-body-te","errorCode":null,"errorMessage":"Failed to parse MCP JSON response: {e} — body: {text}","messagePattern":"Failed to parse MCP JSON response: (.+?) — body: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/openhuman/mcp/http_client/client.rs","lineNumber":809,"sourceCode":"            while let Some(chunk) = stream.next().await {\n                raw.extend_from_slice(&chunk?);\n                // Decode the whole buffer each pass so a multi-byte UTF-8\n                // sequence split across chunk boundaries is never corrupted.\n                if let Some(data) = first_complete_sse_data(&String::from_utf8_lossy(&raw))? {\n                    frame = Some(data);\n                    break;\n                }\n            }\n            match frame {\n                Some(data) => data,\n                // Stream ended without a data frame — fall back to the whole-body\n                // parser for a clear \"no data frame\" error that includes the body.\n                None => parse_sse_message(&String::from_utf8_lossy(&raw))?,\n            }\n        } else {\n            let text = response.text().await?;\n            serde_json::from_str(&text).map_err(|e| {\n                anyhow::anyhow!(\"Failed to parse MCP JSON response: {e} — body: {text}\")\n            })?\n        };\n        if let Some(err) = payload.get(\"error\") {\n            anyhow::bail!(\"MCP error: {err}\");\n        }\n        let result = payload\n            .get(\"result\")\n            .ok_or_else(|| anyhow::anyhow!(\"MCP response missing `result`: {payload}\"))?\n            .clone();\n        Ok(ResponseEnvelope {\n            result,\n            session_id: header_to_string(&headers, HEADER_SESSION_ID),\n        })\n    }\n}\n\n#[cfg(test)]\n#[path = \"client_tests.rs\"]","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/mcp/http_client/client.rs#L791-L827","documentation":"The MCP server's non-SSE HTTP response body was not valid JSON — serde_json::from_str failed on the raw text, which is included in the message. The endpoint may be returning an HTML error page, a proxy interstitial, or a truncated body.","triggerScenarios":"Thrown at src/openhuman/mcp/http_client/client.rs:809 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the logged body snippet to identify HTML error pages or proxy responses","Confirm the URL points at the MCP endpoint, not a human-facing page","Check for corporate TLS-inspection proxies rewriting the response"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}