{"record":{"id":"1fc96edd93fdaa39","repo":"alibaba/spring-ai-alibaba","slug":"http-request-failed-status","errorCode":null,"errorMessage":"HTTP request failed, status: ","messagePattern":"HTTP request failed, status: ","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":788,"sourceCode":"\t * @return Response body as string\n\t */\n\tprivate String sendMessageToServer(AgentCardWrapper agentCard, String requestPayload) throws Exception {\n\t\tString baseUrl = resolveAgentBaseUrl(agentCard);\n\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}","sourceCodeStart":770,"sourceCodeEnd":806,"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#L770-L806","documentation":"sendMessageToServer requires HTTP 200 from the remote A2A endpoint; any other status raises IllegalStateException(\"HTTP request failed, status: \" + statusCode). This is a strict success-only check that surfaces non-200 responses (4xx/5xx, redirects) as exceptions inside the node.","triggerScenarios":"The remote A2A server returns 404 (wrong path), 401/403 (auth required), 500 (server bug), 405 (wrong method), or 3xx redirect, while the client only accepts exactly 200.","commonSituations":"Endpoint path mismatch between the AgentCard.url and the actual JSON-RPC route; missing auth headers/tokens on the remote service; remote agent crashed; gateway returning 502/504; server behind a proxy that answers 301 for http->https redirect.","solutions":["Read the status code in the exception and check the remote server logs for the corresponding error","Correct the AgentCard.url path so it hits the JSON-RPC endpoint exactly","Add required authentication headers if the endpoint returns 401/403","Enable/follow the correct scheme (https) to avoid 3xx redirects the client doesn't follow"],"exampleFix":"// before\nString baseUrl = \"https://host/\"; // returns 404 for JSON-RPC post\n// after\nString baseUrl = \"https://host/a2a/v1\"; // actual JSON-RPC endpoint","handlingStrategy":"retry","validationCode":"// smoke-test the endpoint before agent runs:\n// HttpResponse r = client.execute(new HttpPost(baseUrl)); accept only 200;","typeGuard":null,"tryCatchPattern":"try {\n    String resp = action.sendToServer(card, payload);\n} catch (IllegalStateException e) {\n    int status = Integer.parseInt(e.getMessage().replaceAll(\"\\\\D+\", \"\"));\n    // 5xx/timeout -> retry with backoff; 4xx -> fix URL/auth, don't retry\n}","preventionTips":["Verify the AgentCard.url path matches the remote JSON-RPC route","Configure authentication for endpoints returning 401/403","Use https to avoid 3xx redirects the client won't follow"],"tags":["a2a","http","remote-agent","status-code"],"backgroundTag":"http-non-200-response","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"}