{"record":{"id":"833d6f6e56e9bf43","repo":"alibaba/nacos","slug":"publishrequest-must-not-be-null","errorCode":null,"errorMessage":"publishRequest must not be null","messagePattern":"publishRequest must not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/remote/handler/agent/AgentPublishRpcRequestHandler.java","lineNumber":71,"sourceCode":"    @NamespaceValidation\n    @ExtractorManager.Extractor(rpcExtractor = AgentClientRpcParamExtractor.class)\n    @Secured(action = ActionTypes.WRITE, signType = SignType.AI)\n    public AgentPublishRpcResponse handle(AgentPublishRpcRequest request, RequestMeta meta)\n        throws NacosException {\n        AgentPublishRpcResponse response = new AgentPublishRpcResponse();\n        try {\n            AgentPublishRequest publishRequest = requireRequest(request.getPublishRequest());\n            String namespaceId = NamespaceUtil.processNamespaceParameter(request.getNamespaceId());\n            response.setVersionDetail(publishService.publish(namespaceId, publishRequest));\n        } catch (Exception e) {\n            AgentGrpcResponseErrorMapper.apply(response, e);\n        }\n        return response;\n    }\n    \n    private AgentPublishRequest requireRequest(AgentPublishRequest request) {\n        if (request == null) {\n            throw new IllegalArgumentException(\"publishRequest must not be null\");\n        }\n        return request;\n    }\n}\n","sourceCodeStart":53,"sourceCodeEnd":76,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/remote/handler/agent/AgentPublishRpcRequestHandler.java#L53-L76","documentation":"Thrown (as IllegalArgumentException) by the RAD AgentPublish gRPC handler when the inner `publishRequest` of AgentPublishRpcRequest is null. The type-specific requireRequest(AgentPublishRequest) guard rejects null; AgentGrpcResponseErrorMapper maps it to PARAMETER_VALIDATE_ERROR on the response.","triggerScenarios":"Sending an AgentPublishRpcRequest whose getPublishRequest() returns null. The handler reads the publish request first, resolves the namespace, then delegates to the publish service.","commonSituations":"Code-first agent publication where the outer RPC wrapper is built but the AgentPublishRequest body is omitted; serialization drops the nested field; a refactor changes the field name.","solutions":["Populate AgentPublishRequest (agent definition, version info) before sending.","Assert request.getPublishRequest() != null client-side before the gRPC call.","Build the request through a factory requiring the publish payload."],"exampleFix":"// before\nAgentPublishRpcRequest req = new AgentPublishRpcRequest();\n// publishRequest never set -> error\n\n// after\nreq.setPublishRequest(buildPublishRequest());","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(request.getPublishRequest(), \"publishRequest\");","typeGuard":"boolean hasPublishRequest(AgentPublishRpcRequest r) {\n    return r != null && r.getPublishRequest() != null;\n}","tryCatchPattern":"if (response.getErrorCode() != 0) { handle(response.getMessage()); }","preventionTips":["Ensure the AgentPublishRequest body is set before sending.","Treat a non-zero response error code as the failure signal, not a thrown exception."],"tags":["rad","grpc","validation","agent-publish","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}