alibaba/nacos · error · IllegalArgumentException
${fieldName} must not be null
Error message
${fieldName} must not be null What it means
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.
Source
Thrown at ai/src/main/java/com/alibaba/nacos/ai/remote/handler/agent/AgentSearchRpcRequestHandler.java:71
@ExtractorManager.Extractor(rpcExtractor = AgentClientRpcParamExtractor.class)
@Secured(action = ActionTypes.READ, signType = SignType.AI)
public AgentSearchResponse handle(AgentSearchRpcRequest request, RequestMeta meta)
throws NacosException {
AgentSearchResponse response = new AgentSearchResponse();
try {
requireRequest(request.getSearchRequest(), "searchRequest");
request.getSearchRequest().setNamespaceId(NamespaceUtil.processNamespaceParameter(
request.getSearchRequest().getNamespaceId()));
response.setPage(discoveryService.search(request.getSearchRequest()));
} catch (Exception e) {
AgentGrpcResponseErrorMapper.apply(response, e);
}
return response;
}
private <T> T requireRequest(T value, String fieldName) {
if (value == null) {
throw new IllegalArgumentException(fieldName + " must not be null");
}
return value;
}
}
View on GitHub (pinned to 9b989acdf1)
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.
Example fix
// before AgentSearchRpcRequest req = new AgentSearchRpcRequest(); // searchRequest never set -> error // after req.setSearchRequest(buildSearchRequest());
Defensive patterns
Strategy: validation
Validate before calling
Objects.requireNonNull(request.getSearchRequest(), "searchRequest");
Type guard
boolean hasSearchRequest(AgentSearchRpcRequest r) {
return r != null && r.getSearchRequest() != null;
} Try / catch
if (response.getErrorCode() != 0) { handle(response.getMessage()); } Prevention
- Always attach the nested search criteria to the request.
- Check the response error code/message after the gRPC call.
When it happens
Trigger: Sending an AgentSearchRpcRequest whose getSearchRequest() returns null. The handler validates the inner request first, applies namespace processing, then calls the discovery search service.
Common situations: Client sends the search envelope without the nested search criteria; field-name mismatch during mapping; reusing a request object after clearing its inner field.
Related errors
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/c872b50eb0854525.
Report an issue: GitHub.