{"record":{"id":"e26eeffbfaf1df7c","repo":"alibaba/spring-ai-alibaba","slug":"empty-http-entity","errorCode":null,"errorMessage":"Empty HTTP entity","messagePattern":"Empty HTTP entity","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":792,"sourceCode":"\t\tSystem.out.println(baseUrl);\n\t\tSystem.out.println(requestPayload);\n\t\tif (baseUrl == null || baseUrl.isBlank()) {\n\t\t\tthrow new IllegalStateException(\"AgentCard.url is empty\");\n\t\t}\n\n\t\ttry (CloseableHttpClient httpClient = HttpClients.createDefault()) {\n\t\t\tHttpPost post = new HttpPost(baseUrl);\n\t\t\tpost.setHeader(\"Content-Type\", \"application/json\");\n\t\t\tpost.setEntity(new StringEntity(requestPayload, ContentType.APPLICATION_JSON));\n\n\t\t\ttry (CloseableHttpResponse response = httpClient.execute(post)) {\n\t\t\t\tint statusCode = response.getStatusLine().getStatusCode();\n\t\t\t\tif (statusCode != 200) {\n\t\t\t\t\tthrow new IllegalStateException(\"HTTP request failed, status: \" + statusCode);\n\t\t\t\t}\n\t\t\t\tHttpEntity entity = response.getEntity();\n\t\t\t\tif (entity == null) {\n\t\t\t\t\tthrow new IllegalStateException(\"Empty HTTP entity\");\n\t\t\t\t}\n\t\t\t\treturn EntityUtils.toString(entity, \"UTF-8\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Resolve base URL from the AgentCard.\n\t */\n\tprivate String resolveAgentBaseUrl(AgentCardWrapper agentCard) {\n\t\treturn agentCard.url();\n\t}\n\n}\n","sourceCodeStart":774,"sourceCodeEnd":807,"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#L774-L807","documentation":"After a 200 response, sendMessageToServer reads the response body via response.getEntity(); if the entity is null it throws this IllegalStateException. A 200 without a body cannot be parsed into a JSON-RPC result, so the library fails fast.","triggerScenarios":"The remote A2A endpoint answered 200 but Apache HttpClient provided no entity — typically with 204-like empty responses, HEAD-style gateways, or a misbehaving proxy that strips the body.","commonSituations":"Remote endpoint implemented incorrectly (returns 200 with empty body); server closed the connection after headers; intermediary (nginx/ALB) swallowing empty responses; wrong endpoint (health check route) that returns 200 with no body.","solutions":["Verify you're POSTing to the real JSON-RPC A2A endpoint, not a health/monitoring route that returns 200 with no body","Fix the remote A2A server to always include a JSON-RPC response body on success","Check proxies/gateways for body-stripping or buffering misconfiguration","Add a caller-side try-catch to treat this as an upstream availability problem and retry"],"exampleFix":"// before\n// remote handler: resp.setStatus(200); return; // no body\n// after\n// remote handler: write JSON-RPC result JSON to response output stream, then return","handlingStrategy":"retry","validationCode":"// verify the endpoint returns a JSON body:\n// POST a health JSON-RPC request and assert non-empty body before wiring the node","typeGuard":null,"tryCatchPattern":"try {\n    String resp = action.sendToServer(card, payload);\n} catch (IllegalStateException e) {\n    // treat as upstream availability problem; retry or fail the node gracefully\n}","preventionTips":["Confirm the remote A2A server writes a JSON-RPC body on every 200 response","Avoid routing A2A traffic through health-check or monitoring routes","Review gateway/proxy configs for empty-body handling"],"tags":["a2a","http","empty-body","remote-agent"],"backgroundTag":"empty-response-body","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}