{"record":{"id":"06129df2e93aa795","repo":"alibaba/nacos","slug":"10000","errorCode":"10000","errorMessage":"Request parameter `agentCard` should not be `null` or empty.","messagePattern":"Request parameter `agentCard` should not be `null` or empty\\.","errorType":"validation","errorClass":"NacosApiException","httpStatus":400,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/form/a2a/admin/AgentCardForm.java","lineNumber":46,"sourceCode":"\n/**\n * Agent Card Form request.\n *\n * @author xiweng.yy\n */\npublic class AgentCardForm extends AgentForm {\n    \n    @Serial\n    private static final long serialVersionUID = 8361628138801381818L;\n    \n    private String agentCard;\n    \n    @Override\n    public void validate() throws NacosApiException {\n        fillDefaultNamespaceId();\n        fillDefaultRegistrationType();\n        if (StringUtils.isEmpty(agentCard)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.PARAMETER_MISSING,\n                \"Request parameter `agentCard` should not be `null` or empty.\");\n        }\n        validateRegistrationType();\n        \n    }\n    \n    protected void validateRegistrationType() throws NacosApiException {\n        if (!A2A_ENDPOINT_TYPE_URL.equals(getRegistrationType())\n            && !A2A_ENDPOINT_TYPE_SERVICE.equals(\n                getRegistrationType())) {\n            throw new NacosApiException(NacosException.INVALID_PARAM,\n                ErrorCode.PARAMETER_VALIDATE_ERROR,\n                String.format(\n                    \"Required parameter 'registrationType' value should be `%s` or `%s` but was `%s`\",\n                    A2A_ENDPOINT_TYPE_URL, A2A_ENDPOINT_TYPE_SERVICE, getRegistrationType()));\n        }\n    }\n    ","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/form/a2a/admin/AgentCardForm.java#L28-L64","documentation":"Thrown by AgentValidationUtils.validateProtocol when the protocol token is null, longer than 32 chars, or fails the pattern [A-Za-z0-9][A-Za-z0-9-]{0,31}. A valid protocol starts with an alphanumeric character and continues with alphanumerics or dashes, 1-32 characters total. Underscores, leading dashes, spaces, or symbols are rejected.","triggerScenarios":"Registering a RAD catalog or endpoint with protocol set to an underscore form (\"a2a_rpc\"), a leading dash (\"-a2a\"), null, empty, or >32 chars. Callers include RadModelValidator.validateProtocols, EndpointNaturalKey.of, AgentRuntimeEndpointForm.validate (line 38), RuntimeEndpointRevision, and RadServiceNameComposer.","commonSituations":"Developers reusing snake_case protocol identifiers from another system; copy-pasting a protocol name with trailing whitespace; mismatch between a client's protocol string and the allowed token grammar; version suffixes appended with illegal characters.","solutions":["Use a token like 'A2A-v1', 'mcp', 'grpc', or 'http' (alphanumeric start, dashes only afterwards, <=32 chars).","Trim and null-check the protocol field before request binding.","Centralize protocol constants instead of building them dynamically from user input."],"exampleFix":"// before\nform.setProtocol(\"a2a_rpc\");\n// after\nform.setProtocol(\"a2a-v1\");","handlingStrategy":"validation","validationCode":"if (protocol == null || protocol.length() > 32\n        || !protocol.matches(\"^[A-Za-z0-9][A-Za-z0-9-]{0,31}$\")) {\n    throw new IllegalArgumentException(\"Invalid protocol\");\n}","typeGuard":"static boolean isValidProtocol(String s) {\n    return s != null && s.length() <= 32\n        && s.matches(\"^[A-Za-z0-9][A-Za-z0-9-]{0,31}$\");\n}","tryCatchPattern":"try {\n    AgentValidationUtils.validateProtocol(protocol);\n} catch (IllegalArgumentException e) {\n    // return 400, field 'protocol'\n}","preventionTips":["Centralize protocol identifiers as constants.","Avoid snake_case; the grammar allows only alnum and dash."],"tags":["ai-agent","validation","protocol","rad","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}