{"record":{"id":"3707b6440458b460","repo":"alibaba/spring-ai-alibaba","slug":"agentcard-url-is-empty","errorCode":null,"errorMessage":"AgentCard.url is empty","messagePattern":"AgentCard\\.url is empty","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":777,"sourceCode":"\t\t\treturn template.render(state.data());\n\t\t} else if (!shareState || (shareState && state.value(\"messages\").isEmpty())) {\n\t\t\tthrow new IllegalStateException(\"Instruction is empty and shareState is false\");\n\t\t}\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * Send the request to the remote A2A server and return the non-streaming response.\n\t * @param agentCard Agent card (source for server URL/metadata)\n\t * @param requestPayload JSON string payload built by buildSendMessageRequest\n\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}","sourceCodeStart":759,"sourceCodeEnd":795,"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#L759-L795","documentation":"sendMessageToServer resolves the base URL from the AgentCard and refuses to issue an HTTP request when it is null or blank, throwing this IllegalStateException. The A2A client needs the remote agent's endpoint URL to POST the JSON-RPC request.","triggerScenarios":"AgentCard.url is not set by the A2A server's agent card response, or resolveAgentBaseUrl returns null/blank (card fetched from a registry like Nacos without a URL, or a misregistered service).","commonSituations":"Remote agent registered in Nacos without its URL; agent card served by a placeholder/stub; DNS-less or unconfigured deployment where the card was hand-built; older agent publishing a card lacking the url field.","solutions":["Fix the remote agent's AgentCard so url points at its A2A endpoint","If using Nacos/registry discovery, re-register the service with the correct URL/IP and port","Validate the card before building the node: if (card.url() == null || card.url().isBlank()) fail fast with a clear config error","Pin the URL explicitly in your configuration instead of relying on the card if discovery is unreliable"],"exampleFix":"// before\n// remote publishes: AgentCard.builder().name(\"writer\").build() // no url\n// after\nAgentCard card = AgentCard.builder()\n    .name(\"writer\")\n    .url(\"http://10.0.0.5:8080/a2a\")\n    .build();","handlingStrategy":"validation","validationCode":"if (agentCard.url() == null || agentCard.url().isBlank()) {\n    throw new IllegalArgumentException(\"AgentCard has no url; fix remote registration before invoking\");\n}","typeGuard":"boolean hasUrl(AgentCardWrapper c) { return c != null && c.url() != null && !c.url().isBlank(); }","tryCatchPattern":"try {\n    String resp = action.sendToServer(card, payload);\n} catch (IllegalStateException e) {\n    // re-resolve agent card from registry or use a configured fallback URL\n}","preventionTips":["Validate the agent card right after fetching it from Nacos/registry","Re-register remote agents with explicit host:port URLs","Prefer explicit configured URLs when discovery is unreliable"],"tags":["a2a","agent-card","url","discovery"],"backgroundTag":"empty-required-field","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}