conductor-oss/conductor · error · RuntimeException
Failed to parse SSE data as JSON: {jsonData}
Error message
Failed to parse SSE data as JSON: {jsonData} What it means
Thrown by parseSseResponse when data: lines were found and concatenated but objectMapper.readTree failed to parse the result as JSON. The error includes the concatenated jsonData that failed. Means the SSE payload, after extraction, was not valid JSON (truncation, mixed content, or non-JSON data frames).
Source
Thrown at ai/src/main/java/org/conductoross/conductor/ai/mcp/MCPService.java:371
for (String line : lines) {
String trimmed = line.trim();
if (trimmed.startsWith("data:")) {
String data = trimmed.substring(5).trim();
// Skip empty data or "[DONE]" markers
if (!data.isEmpty() && !data.equals("[DONE]")) {
jsonData.append(data);
}
}
}
if (jsonData.length() == 0) {
throw new RuntimeException("No data found in SSE response: " + sseBody);
}
try {
return objectMapper.readTree(jsonData.toString());
} catch (Exception e) {
throw new RuntimeException("Failed to parse SSE data as JSON: " + jsonData, e);
}
}
/** Executes one MCP request and follows redirects while protecting sensitive headers. */
private ResponsePayload execute(Request initialRequest) throws Exception {
Request request = initialRequest;
for (int redirects = 0; redirects <= 5; redirects++) {
try (Response response = httpClient.newCall(request).execute()) {
if (!response.isRedirect()) {
return new ResponsePayload(
response.code(),
response.header("Content-Type", "application/json"),
readBoundedBody(response.body()));
}
String location = response.header("Location");
if (location == null || request.url().resolve(location) == null) {
throw new RuntimeException(
"MCP server returned a redirect without a valid Location");View on GitHub (pinned to cf7c3e4a8a)
Solutions
- Inspect the concatenated jsonData in the message — if it looks like fragments joined without newlines, the server splits objects across data: lines and this parser mishandles them.
- If multiple JSON objects appear, the server is emitting NDJSON; pick the JSON-RPC response object specifically.
- Ensure the body wasn't truncated by the 10 MiB read limit (would surface as 175/176 instead).
- Use a spec-compliant SSE client that reassembles multi-line data: fields correctly.
Defensive patterns
Strategy: try-catch
Try / catch
try {
mcpService.listTools(serverUrl, headers);
} catch (RuntimeException e) {
if (e.getMessage().contains("Failed to parse SSE data as JSON")) {
// concatenated data: lines were not valid JSON; inspect them (in message)
}
throw e;
} Prevention
- Inspect the concatenated data in the message to spot multi-line-fragment or NDJSON issues.
- Prefer servers that send each JSON-RPC response as a single data: line.
- If the server splits objects across data: lines, consider a compliant SSE parser.
When it happens
Trigger: SSE data: lines were partial JSON fragments that were concatenated incorrectly (this parser simply joins them, so multi-line JSON objects split across data: lines can mis-concatenate); server emitted NDJSON (multiple JSON objects) instead of one; data was truncated; data contained a non-JSON text payload.
Common situations: Server splits one JSON object across multiple `data:` lines without leading spaces (the code does .trim() on each, so the spec-mandated single leading space is lost and fragments may join wrong); server streaming multiple JSON values; proxy truncated the body.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- No data found in SSE response: {sseBody}
- Invalid JSON-RPC response: missing 'result' field
- Invalid response: 'tools' field is missing or not an array
- No data found in SSE response: {sseBody}
- HTTP %d error from MCP server: %s
AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14).
Data as JSON: /api/errors/16c682ec272e11bb.
Report an issue: GitHub.