{"record":{"id":"ea528e687f9a0871","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-parse-any-valid-result-from-streaming-re","errorCode":null,"errorMessage":"Failed to parse any valid result from streaming response","messagePattern":"Failed to parse any valid result from streaming response","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/a2a/A2aNodeActionWithConfig.java","lineNumber":537,"sourceCode":"\t\t\t\ttry {\n\t\t\t\t\tMap<String, Object> parsed = JSON.parseObject(jsonContent,\n\t\t\t\t\t\t\tnew TypeReference<Map<String, Object>>() {\n\t\t\t\t\t\t\t});\n\t\t\t\t\tMap<String, Object> result = (Map<String, Object>) parsed.get(\"result\");\n\t\t\t\t\tif (result != null) {\n\t\t\t\t\t\tif (result.containsKey(\"artifact\") || lastResult == null) {\n\t\t\t\t\t\t\tlastResult = result;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (lastResult == null) {\n\t\t\tthrow new IllegalStateException(\"Failed to parse any valid result from streaming response\");\n\t\t}\n\t\tMap<String, Object> resultMap = new HashMap<>();\n\t\tresultMap.put(\"result\", lastResult);\n\t\treturn resultMap;\n\t}\n\n\tprivate String extractResponseText(Map<String, Object> result) {\n\t\tif (result == null) {\n\t\t\tthrow new IllegalStateException(\"Result is null, cannot extract response text\");\n\t\t}\n\n\t\tif (\"status-update\".equals(result.get(\"kind\"))) {\n\t\t\tMap<String, Object> status = (Map<String, Object>) result.get(\"status\");\n\t\t\tif (status != null) {\n\t\t\t\tString state = (String) status.get(\"state\");\n\t\t\t\tif (\"completed\".equals(state)) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/a2a/A2aNodeActionWithConfig.java#L519-L555","documentation":"parseStreamingResponse iterates SSE/stream chunks from an A2A server trying to extract a valid result; if no chunk could be parsed into a usable result by the end of the stream, it throws this IllegalStateException. It means the remote agent streamed nothing parseable (or only heartbeat/unknown events).","triggerScenarios":"Calling autoDetectAndParseResponse -> parseStreamingResponse against an A2A endpoint whose message/stream response yields no chunk matching the expected shapes (status-update, artifact-update, JSON-RPC result), or the stream closes immediately.","commonSituations":"Remote A2A server returns an error event or empty stream; server version speaks a different A2A protocol shape than the parser expects; network proxy truncates the SSE stream before any data event; wrong endpoint URL returning HTML error page.","solutions":["Verify the remote A2A server is up and the AgentCard.url points to the JSON-RPC/stream endpoint, not a UI or docs page","Check server-side logs for the request; ensure the agent actually emits message/stream events (status-update/artifact-update)","Upgrade or align the A2A protocol version on both client and server so event shapes match what parseStreamingResponse expects","Wrap the call and retry or fall back to the non-streaming message/send endpoint"],"exampleFix":"// before\nString url = \"https://host/\"; // UI root, not the A2A endpoint\n// after\nString url = agentCard.url(); // e.g. https://host/a2a/v1","handlingStrategy":"retry","validationCode":"// pre-check: ensure the endpoint answers before streaming\n// e.g. fetch agent card: if (agentCard.url() == null || agentCard.url().isBlank()) fail fast;","typeGuard":null,"tryCatchPattern":"try {\n    Map<String,Object> result = action.autoDetectAndParseResponse(...);\n} catch (IllegalStateException e) {\n    // log stream contents/endpoint, retry once, then fall back to non-streaming message/send\n}","preventionTips":["Point AgentCard.url at the actual A2A JSON-RPC/stream endpoint","Confirm the remote agent emits status-update/artifact-update events","Keep client and server A2A protocol versions aligned"],"tags":["a2a","streaming","sse","parsing"],"backgroundTag":"unexpected-response-shape","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}