{"record":{"id":"2d45dbfb57ca9811","repo":"nikivdev/code","slug":"maple-mcp-request-failed","errorCode":null,"errorMessage":"Maple MCP request failed ({}): {}","messagePattern":"Maple MCP request failed \\((.+?)\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/codex_telemetry.rs","lineNumber":406,"sourceCode":"        .context(\"failed to build Maple MCP client\")?;\n    let request = serde_json::json!({\n        \"jsonrpc\": \"2.0\",\n        \"id\": 1,\n        \"method\": method,\n        \"params\": params,\n    });\n    let response = client\n        .post(&config.endpoint)\n        .bearer_auth(&config.token)\n        .json(&request)\n        .send()\n        .with_context(|| format!(\"failed to reach Maple MCP at {}\", config.endpoint))?;\n    let status = response.status();\n    let payload: serde_json::Value = response\n        .json()\n        .context(\"failed to parse Maple MCP response JSON\")?;\n    if !status.is_success() {\n        anyhow::bail!(\n            \"Maple MCP request failed ({}): {}\",\n            status,\n            serde_json::to_string(&payload)\n                .unwrap_or_else(|_| \"unparseable error body\".to_string())\n        );\n    }\n    let envelope = if let Some(items) = payload.as_array() {\n        items.first().cloned().unwrap_or(serde_json::Value::Null)\n    } else {\n        payload\n    };\n    if let Some(error) = envelope.get(\"error\") {\n        let code = error\n            .get(\"code\")\n            .and_then(serde_json::Value::as_i64)\n            .unwrap_or(-1);\n        let message = error\n            .get(\"message\")","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/codex_telemetry.rs#L388-L424","documentation":"This error is raised by `maple_json_rpc_request` in src/codex_telemetry.rs when the Maple MCP HTTP endpoint returns a non-success HTTP status. The library embeds the status code and the raw response body (JSON-serialized, falling back to 'unparseable error body') so the caller can see exactly why the server rejected the JSON-RPC request. It wraps the two earlier failure points (connection failure, JSON parse failure) with an explicit server-side rejection signal.","triggerScenarios":"`maple_json_rpc_request` (called by `maple_call_tool` and `trace_status`) receives an HTTP response whose status is not a success (e.g. 401 Unauthorized from a bad/missing MAPLE_API_TOKEN, 404 from a wrong endpoint path, 500 from a Maple server fault), and bails with the status plus body.","commonSituations":"Expired or missing MAPLE_API_TOKEN, misconfigured MAPLE_MCP_ENDPOINT pointing at the wrong port/path, Maple MCP service down or restarting, proxy/firewall returning an error page, or a version mismatch where the endpoint no longer accepts a given JSON-RPC method.","solutions":["Read the status and body in the message: fix auth (401/403) by exporting a valid MAPLE_API_TOKEN, fix the URL (404) by correcting the endpoint config, or retry later (5xx) once the Maple service is healthy.","Verify connectivity with curl: `curl -i \"$MAPLE_MCP_ENDPOINT\"` and confirm the server responds at the configured path.","Check that the Maple MCP server version supports the JSON-RPC method being invoked (maple_call_tool / trace_status).","Inspect proxy environment variables (HTTP_PROXY/HTTPS_PROXY) that may intercept the request."],"exampleFix":"// before: endpoint misconfigured\nMAPLE_MCP_ENDPOINT=http://localhost:9999/wrong\n// after\nMAPLE_MCP_ENDPOINT=http://localhost:8080/mcp","handlingStrategy":"try-catch","validationCode":"// preflight the endpoint before making calls\nlet endpoint = std::env::var(\"MAPLE_MCP_ENDPOINT\")?;\nlet ok = reqwest::Client::new()\n    .get(&endpoint)\n    .timeout(std::time::Duration::from_secs(5))\n    .send()\n    .map(|r| r.status().as_u16())\n    .map_err(|e| format!(\"unreachable: {e}\"));\nif let Ok(code) = &ok { if !(200..300).contains(code) { return Err(format!(\"endpoint unhealthy: {code}\")); } }","typeGuard":"fn is_success_response(resp: &reqwest::Response) -> bool { resp.status().is_success() }","tryCatchPattern":"match maple_call_tool(name, args) {\n    Err(e) if e.to_string().contains(\"Maple MCP request failed (\") => {\n        // parse the status out of the message; 401/403 -> refresh token, 5xx -> retry later\n        eprintln!(\"Maple endpoint rejected request: {e:#}\");\n    }\n    Err(e) => return Err(e),\n    Ok(result) => result,\n}","preventionTips":["Validate MAPLE_API_TOKEN and MAPLE_MCP_ENDPOINT with a cheap health check before batch operations","Log the HTTP status and body on every Maple call","Monitor Maple service health/uptime before long telemetry runs","Pin and document the expected MCP server version"],"tags":["network","http","mcp","json-rpc","api"],"backgroundTag":"http-non-2xx-response","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}