{"record":{"id":"0d1af7cb11af7568","repo":"alibaba/nacos","slug":"invalid-param","errorCode":"INVALID_PARAM","errorMessage":"parameter `type` should be %s or %s, but was %s","messagePattern":"parameter `type` should be (.+?) or (.+?), but was (.+?)","errorType":"exception","errorClass":"NacosApiException","httpStatus":400,"severity":"warning","filePath":"ai/src/main/java/com/alibaba/nacos/ai/remote/handler/a2a/AgentEndpointRequestHandler.java","lineNumber":116,"sourceCode":"                handleCanonical(request, meta);\n                return response;\n            }\n            Instance instance = transferInstance(request);\n            String serviceName =\n                agentIdCodecHolder.encode(request.getAgentName()) + \"::\"\n                    + request.getEndpoint().getVersion();\n            Service service =\n                Service.newService(request.getNamespaceId(), Constants.Agent.AGENT_ENDPOINT_GROUP,\n                    serviceName);\n            switch (request.getType()) {\n                case AiRemoteConstants.REGISTER_ENDPOINT:\n                    doRegisterEndpoint(service, instance, meta);\n                    break;\n                case AiRemoteConstants.DE_REGISTER_ENDPOINT:\n                    doDeregisterEndpoint(service, instance, meta);\n                    break;\n                default:\n                    throw new NacosApiException(NacosException.INVALID_PARAM,\n                        ErrorCode.PARAMETER_VALIDATE_ERROR,\n                        String.format(\"parameter `type` should be %s or %s, but was %s\",\n                            AiRemoteConstants.REGISTER_ENDPOINT,\n                            AiRemoteConstants.DE_REGISTER_ENDPOINT, request.getType()));\n            }\n        } catch (NacosApiException e) {\n            response.setErrorInfo(e.getErrCode(), e.getErrMsg());\n            LOGGER.error(\"[{}] Register agent endpoint to agent {} error: {}\",\n                meta.getConnectionId(),\n                request.getAgentName(), e.getErrMsg());\n        }\n        return response;\n    }\n    \n    private void handleCanonical(AgentEndpointRequest request, RequestMeta meta)\n        throws NacosException {\n        switch (request.getType()) {\n            case AiRemoteConstants.REGISTER_ENDPOINT:","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/remote/handler/a2a/AgentEndpointRequestHandler.java#L98-L134","documentation":"Thrown by the default branch of the type switch in AgentEndpointRequestHandler.handle() (legacy/non-canonical A2A path) when request.getType() is neither REGISTER_ENDPOINT ('registerEndpoint') nor DE_REGISTER_ENDPOINT ('deregisterEndpoint'). Mapped to PARAMETER_VALIDATE_ERROR detail code under an INVALID_PARAM top-level code; caught and placed into the AgentEndpointResponse error info. Available since 3.1.0.","triggerScenarios":"A gRPC AgentEndpointRequest whose type is null, empty, or any value other than the two recognized constants, AND the compatibility mode is not CANONICAL (the canonical path has its own equivalent check).","commonSituations":"Client sends a raw string type that is mistyped; client leaves type null; version skew in the A2A protocol constants; sending BATCH_REGISTER_ENDPOINT to the single-endpoint handler.","solutions":["Set request.setType to AiRemoteConstants.REGISTER_ENDPOINT or AiRemoteConstants.DE_REGISTER_ENDPOINT.","Use the SDK typed constants instead of hand-coded strings.","Confirm you are calling the single endpoint handler and not the batch handler."],"exampleFix":"// before\nreq.setType(\"register\");\n\n// after\nreq.setType(AiRemoteConstants.REGISTER_ENDPOINT);","handlingStrategy":"validation","validationCode":"String t = request.getType();\nif (!AiRemoteConstants.REGISTER_ENDPOINT.equals(t)\n    && !AiRemoteConstants.DE_REGISTER_ENDPOINT.equals(t)) {\n    throw new IllegalArgumentException(\"AgentEndpointRequest.type must be registerEndpoint or deregisterEndpoint\");\n}","typeGuard":null,"tryCatchPattern":"AgentEndpointResponse resp = handler.handle(request, meta);\nif (resp.getErrCode() != 0 && resp.getErrMsg().contains(\"type should\")) {\n    // fix the type constant and retry\n}","preventionTips":["Use AiRemoteConstants for type values; never hard-code strings.","Do not send batch type values to the single AgentEndpointRequest handler.","Check the AgentEndpointResponse error info after the call rather than expecting an exception."],"tags":["ai","a2a-agent","grpc","validation","endpoint","parameter"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}