{"record":{"id":"dd68b2c55a271035","repo":"conductor-oss/conductor","slug":"invalid-json-rpc-response-missing-result-field","errorCode":null,"errorMessage":"Invalid JSON-RPC response: missing 'result' field","messagePattern":"Invalid JSON-RPC response: missing 'result' field","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/mcp/MCPService.java","lineNumber":154,"sourceCode":"            String contentType = response.contentType;\n\n            // Parse response based on content type\n            JsonNode responseJson;\n            if (contentType != null && contentType.contains(\"text/event-stream\")) {\n                // Parse SSE format\n                responseJson = parseSseResponse(responseBody);\n            } else {\n                // Parse as JSON directly\n                responseJson = objectMapper.readTree(responseBody);\n            }\n\n            if (responseJson.has(\"error\")) {\n                throw new RuntimeException(\n                        \"JSON-RPC error: \" + responseJson.get(\"error\").toString());\n            }\n\n            if (!responseJson.has(\"result\")) {\n                throw new RuntimeException(\"Invalid JSON-RPC response: missing 'result' field\");\n            }\n\n            JsonNode result = responseJson.get(\"result\");\n            JsonNode toolsNode = result.get(\"tools\");\n\n            if (toolsNode == null || !toolsNode.isArray()) {\n                throw new RuntimeException(\n                        \"Invalid response: 'tools' field is missing or not an array\");\n            }\n            ExternalDataLimits.validateStructure(objectMapper.convertValue(result, Object.class));\n\n            // Convert to McpSchema.Tool list\n            // Use Jackson to deserialize tools directly (same pattern as stdio implementation)\n            List<McpSchema.Tool> tools =\n                    objectMapper.convertValue(\n                            toolsNode,\n                            objectMapper\n                                    .getTypeFactory()","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/mcp/MCPService.java#L136-L172","documentation":"Thrown by listToolsDirectHttp when the JSON-RPC response has neither an `error` nor a `result` field. Per JSON-RPC 2.0 a valid response to a request must contain exactly one of result/error; absence of both means the server returned a structurally non-conformant payload (e.g. just an ack, or an SSE event that was not a JSON-RPC response).","triggerScenarios":"Server returns `{\"jsonrpc\":\"2.0\",\"id\":1}` with no result/error; server returns a notification-style or progress message as the response; SSE stream delivered only keep-alive/event frames and no data payload that resolved to a JSON-RPC response object.","commonSituations":"Hitting a server that streams server-sent events where the first non-data frames were concatenated; pointing at an endpoint that returns metadata instead of a JSON-RPC response; mismatched transport expectation (server is SSE-only but content-type was not text/event-stream).","solutions":["Capture the raw response body to confirm what the server actually returned (it was logged at debug).","Verify the endpoint is a JSON-RPC responder and not an event-stream info endpoint.","Ensure the Accept header negotiated a transport the server uses to send the JSON-RPC result back.","If the server only speaks SSE, confirm content-type detection worked so parseSseResponse was invoked."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    mcpService.listTools(serverUrl, headers);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"missing 'result' field\")) {\n        // server returned a non-JSON-RPC envelope; log body and check endpoint/transport\n    }\n    throw e;\n}","preventionTips":["Verify the endpoint returns a JSON-RPC response object, not metadata or notifications.","Capture raw bodies in debug logs to spot malformed envelopes.","Confirm SSE vs JSON transport matches the server's actual response type."],"tags":["mcp","json-rpc","malformed-response","protocol"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}