alibaba/nacos · error · IllegalArgumentException
AgentVersionContent JSON must not be empty
Error message
AgentVersionContent JSON must not be empty
What it means
Thrown by validateSingleJsonValue when the JSON parser yields no tokens at all — the byte array is empty or contains only whitespace/comments that produce zero JSON tokens. Persisted content must be a non-empty JSON value.
Source
Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java:274
Map<?, ?> interfaceObject = (Map<?, ?>) callInterface;
rejectUnknownFields(interfaceObject, CALL_INTERFACE_FIELDS, "AgentCallInterface");
Object endpoints = interfaceObject.get("declaredEndpoints");
if (!(endpoints instanceof List)) {
continue;
}
for (Object endpoint : (List<?>) endpoints) {
if (endpoint instanceof Map) {
rejectUnknownFields((Map<?, ?>) endpoint, ENDPOINT_FIELDS,
"DeclaredEndpoint");
}
}
}
}
private static void validateSingleJsonValue(byte[] bytes) {
try (JsonParser parser = STRICT_JSON_FACTORY.createParser(bytes)) {
if (parser.nextToken() == null) {
throw new IllegalArgumentException("AgentVersionContent JSON must not be empty");
}
parser.skipChildren();
if (parser.nextToken() != null) {
throw new IllegalArgumentException(
"AgentVersionContent must contain one JSON value");
}
} catch (IOException e) {
throw new IllegalArgumentException("Invalid AgentVersionContent", e);
}
}
private static void rejectUnknownFields(Map<?, ?> value, Set<String> fields,
String objectName) {
for (Object field : value.keySet()) {
if (!fields.contains(field)) {
throw new IllegalArgumentException("Unknown " + objectName + " field: " + field);
}
}View on GitHub (pinned to 9b989acdf1)
Solutions
- Ensure content is always serialized through serialize() which produces non-empty JSON.
- Restore or re-publish the version if the stored bytes are empty.
- Guard empty bytes before calling deserialize.
Defensive patterns
Strategy: validation
Validate before calling
if (bytes == null || bytes.length == 0) {
throw new NacosException(NacosException.SERVER_ERROR, "empty content bytes");
} Prevention
- Guard empty bytes before deserialize.
- Ensure write paths never persist empty cells.
When it happens
Trigger: Deserializing a zero-length byte array, or bytes containing only whitespace. The strict Jackson parser's first nextToken() returns null.
Common situations: A storage cell was written empty, or a truncation left zero bytes. Also in tests passing new byte[0].
Related errors
- AgentVersionContent must be a JSON object
- AgentVersionContent must contain one JSON value
- Invalid AgentVersionContent
- Unknown {objectName} field: {field}
- 20002
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/8eaf0df9bf17ef13.
Report an issue: GitHub.