alibaba/nacos · error · IllegalArgumentException
Agent publish request must not be null
Error message
Agent publish request must not be null
What it means
The AgentPublishApplicationService.publish method requires a non-null AgentPublishRequest. This is the entry guard for the idempotent Agent draft-and-submit pipeline used by the client publish API. A null request means no publication data was provided, which is a programming or binding error.
Source
Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/agent/AgentPublishApplicationService.java:59
private final AgentOperationService operationService;
public AgentPublishApplicationService(AgentOperationService operationService) {
this.operationService = operationService;
}
/**
* Publish one exact Agent Version and optionally submit it.
*
* @param namespaceId effective namespace
* @param request publication request
* @return resulting exact Version detail
* @throws NacosException when validation, persistence, or submit fails
*/
public AgentVersionDetail publish(String namespaceId, AgentPublishRequest request)
throws NacosException {
if (request == null) {
throw new IllegalArgumentException("Agent publish request must not be null");
}
AgentValidationUtils.validateNamespaceId(namespaceId);
request.validate();
AgentVersionDetail current = findEquivalent(namespaceId, request);
if (current == null) {
try {
current = operationService.createDraft(namespaceId, request);
} catch (NacosException createFailure) {
current = recoverEquivalent(namespaceId, request, createFailure);
}
}
if (!request.isAutoSubmit()) {
requireStatus(current, AiConstants.Agent.VERSION_STATUS_DRAFT);
return current;
}
if (!AiConstants.Agent.VERSION_STATUS_DRAFT.equals(current.getStatus())) {
return requireSubmittedState(current);
}View on GitHub (pinned to 9b989acdf1)
Solutions
- Construct and populate an AgentPublishRequest before calling publish.
- Validate non-null at the controller/client boundary before delegating to the service.
- Ensure the HTTP request body is valid JSON with agentName, version, and callInterfaces.
Example fix
// before
service.publish(ns, null); // throws
// after
AgentPublishRequest req = new AgentPublishRequest();
req.setAgentName("my-agent");
req.setVersion("1.0.0");
req.setCallInterfaces(List.of(callInterface));
req.setAutoSubmit(true);
service.publish(ns, req); Defensive patterns
Strategy: validation
Validate before calling
if (request == null) {
throw new IllegalArgumentException("Agent publish request must not be null");
} Type guard
boolean isPublishable(AgentPublishRequest req) {
return req != null && req.getAgentName() != null && req.getVersion() != null
&& req.getCallInterfaces() != null;
} Prevention
- Validate the request object is non-null before calling publish.
- Use @RequestBody(required = true) at the controller to reject empty bodies early.
- Construct AgentPublishRequest via a builder that enforces required fields.
When it happens
Trigger: Calling AgentPublishApplicationService.publish(namespaceId, null), or the client publish API endpoint with a missing/empty request body that deserializes to null.
Common situations: An SDK caller passes null instead of a constructed request. The HTTP request body is empty or malformed. A retry or callback invokes publish without reconstructing the request object.
Related errors
- Agent replacement must not be null
- AgentResourceExt must not be null
- Online Agent Version must contain callInterfaces
- Agent Version namespaceId does not match request
- Agent Version agentName does not match request
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/cd40d76d7d1e414f.
Report an issue: GitHub.