{"record":{"id":"c872b50eb0854525","repo":"alibaba/nacos","slug":"fieldname-must-not-be-null-c872b5","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/AgentSearchRpcRequestHandler.java","lineNumber":71,"sourceCode":"    @ExtractorManager.Extractor(rpcExtractor = AgentClientRpcParamExtractor.class)\n    @Secured(action = ActionTypes.READ, signType = SignType.AI)\n    public AgentSearchResponse handle(AgentSearchRpcRequest request, RequestMeta meta)\n        throws NacosException {\n        AgentSearchResponse response = new AgentSearchResponse();\n        try {\n            requireRequest(request.getSearchRequest(), \"searchRequest\");\n            request.getSearchRequest().setNamespaceId(NamespaceUtil.processNamespaceParameter(\n                request.getSearchRequest().getNamespaceId()));\n            response.setPage(discoveryService.search(request.getSearchRequest()));\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":53,"sourceCodeEnd":76,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/remote/handler/agent/AgentSearchRpcRequestHandler.java#L53-L76","documentation":"Thrown (as IllegalArgumentException) by the RAD AgentSearch gRPC handler when the inner `searchRequest` of AgentSearchRpcRequest is null. The requireRequest() guard rejects it; AgentGrpcResponseErrorMapper maps the exception to PARAMETER_VALIDATE_ERROR on the response.","triggerScenarios":"Sending an AgentSearchRpcRequest whose getSearchRequest() returns null. The handler validates the inner request first, applies namespace processing, then calls the discovery search service.","commonSituations":"Client sends the search envelope without the nested search criteria; field-name mismatch during mapping; reusing a request object after clearing its inner field.","solutions":["Set a non-null search request (with query/page parameters) before sending.","Assert request.getSearchRequest() != null client-side before invoking search.","Construct the outer request via a builder that mandates the inner searchRequest."],"exampleFix":"// before\nAgentSearchRpcRequest req = new AgentSearchRpcRequest();\n// searchRequest never set -> error\n\n// after\nreq.setSearchRequest(buildSearchRequest());","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(request.getSearchRequest(), \"searchRequest\");","typeGuard":"boolean hasSearchRequest(AgentSearchRpcRequest r) {\n    return r != null && r.getSearchRequest() != null;\n}","tryCatchPattern":"if (response.getErrorCode() != 0) { handle(response.getMessage()); }","preventionTips":["Always attach the nested search criteria to the request.","Check the response error code/message after the gRPC call."],"tags":["rad","grpc","validation","agent-search","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}