alibaba/nacos · error · IllegalArgumentException
publishRequest must not be null
Error message
publishRequest must not be null
What it means
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.
Source
Thrown at ai/src/main/java/com/alibaba/nacos/ai/remote/handler/agent/AgentPublishRpcRequestHandler.java:71
@NamespaceValidation
@ExtractorManager.Extractor(rpcExtractor = AgentClientRpcParamExtractor.class)
@Secured(action = ActionTypes.WRITE, signType = SignType.AI)
public AgentPublishRpcResponse handle(AgentPublishRpcRequest request, RequestMeta meta)
throws NacosException {
AgentPublishRpcResponse response = new AgentPublishRpcResponse();
try {
AgentPublishRequest publishRequest = requireRequest(request.getPublishRequest());
String namespaceId = NamespaceUtil.processNamespaceParameter(request.getNamespaceId());
response.setVersionDetail(publishService.publish(namespaceId, publishRequest));
} catch (Exception e) {
AgentGrpcResponseErrorMapper.apply(response, e);
}
return response;
}
private AgentPublishRequest requireRequest(AgentPublishRequest request) {
if (request == null) {
throw new IllegalArgumentException("publishRequest must not be null");
}
return request;
}
}
View on GitHub (pinned to 9b989acdf1)
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.
Example fix
// before AgentPublishRpcRequest req = new AgentPublishRpcRequest(); // publishRequest never set -> error // after req.setPublishRequest(buildPublishRequest());
Defensive patterns
Strategy: validation
Validate before calling
Objects.requireNonNull(request.getPublishRequest(), "publishRequest");
Type guard
boolean hasPublishRequest(AgentPublishRpcRequest r) {
return r != null && r.getPublishRequest() != null;
} Try / catch
if (response.getErrorCode() != 0) { handle(response.getMessage()); } Prevention
- Ensure the AgentPublishRequest body is set before sending.
- Treat a non-zero response error code as the failure signal, not a thrown exception.
When it happens
Trigger: Sending an AgentPublishRpcRequest whose getPublishRequest() returns null. The handler reads the publish request first, resolves the namespace, then delegates to the publish service.
Common situations: 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.
Related errors
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/833d6f6e56e9bf43.
Report an issue: GitHub.