{"record":{"id":"5221b762479201ca","repo":"alibaba/nacos","slug":"fieldname-must-not-be-null-5221b7","errorCode":null,"errorMessage":"${fieldName} must not be null","messagePattern":"(.+?) must not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/remote/handler/agent/AgentEndpointRegisterRpcRequestHandler.java","lineNumber":74,"sourceCode":"    @Secured(action = ActionTypes.WRITE, signType = SignType.AI)\n    public AgentEndpointOperationResponse handle(AgentEndpointRegisterRpcRequest request,\n        RequestMeta meta) throws NacosException {\n        AgentEndpointOperationResponse response = new AgentEndpointOperationResponse();\n        try {\n            AgentEndpointRegistrationBatch batch =\n                requireRequest(request.getRegistrationBatch(), \"registrationBatch\");\n            batch.setNamespaceId(NamespaceUtil.processNamespaceParameter(\n                batch.getNamespaceId()));\n            runtimeRegistryService.register(meta.getConnectionId(), batch);\n        } catch (Exception e) {\n            AgentGrpcResponseErrorMapper.apply(response, e);\n        }\n        return response;\n    }\n    \n    private <T> T requireRequest(T value, String fieldName) {\n        if (value == null) {\n            throw new IllegalArgumentException(fieldName + \" must not be null\");\n        }\n        return value;\n    }\n}\n","sourceCodeStart":56,"sourceCodeEnd":79,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/remote/handler/agent/AgentEndpointRegisterRpcRequestHandler.java#L56-L79","documentation":"Thrown (as IllegalArgumentException) by the RAD AgentEndpointRegister gRPC handler when the inner `registrationBatch` of AgentEndpointRegisterRpcRequest is null. The requireRequest() guard rejects it; AgentGrpcResponseErrorMapper maps the exception to PARAMETER_VALIDATE_ERROR on the response.","triggerScenarios":"Sending an AgentEndpointRegisterRpcRequest whose getRegistrationBatch() returns null. The handler validates the batch first, then applies namespace processing and delegates to the runtime registry.","commonSituations":"Client sends the outer envelope without the AgentEndpointRegistrationBatch payload; field name mismatch during serialization; conditional code that skips batch construction.","solutions":["Set a non-null AgentEndpointRegistrationBatch on the request before sending.","Add a client-side precondition: Objects.requireNonNull(request.getRegistrationBatch()).","Use a builder that enforces the batch as a required parameter."],"exampleFix":"// before\nAgentEndpointRegisterRpcRequest req = new AgentEndpointRegisterRpcRequest();\n// registrationBatch never set -> error\n\n// after\nreq.setRegistrationBatch(buildBatch());","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(request.getRegistrationBatch(), \"registrationBatch\");","typeGuard":"boolean hasBatch(AgentEndpointRegisterRpcRequest r) {\n    return r != null && r.getRegistrationBatch() != null;\n}","tryCatchPattern":"if (response.getErrorCode() != 0) { handle(response.getMessage()); }","preventionTips":["Construct the outer request through a builder that mandates the batch payload.","Inspect response error code rather than expecting a thrown exception."],"tags":["rad","grpc","validation","agent-endpoint","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}