alibaba/nacos · error · IllegalArgumentException
AgentVersionContent kind must be {AgentVersionContent.KIND}
Error message
AgentVersionContent kind must be {AgentVersionContent.KIND} What it means
Thrown by validate when content.getKind() does not equal the constant AgentVersionContent.KIND ("AgentVersionContent"). The kind field is a discriminator ensuring persisted content is self-identifying and resistant to schema confusion.
Source
Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java:147
"AgentVersionContent exceeds " + MAX_CONTENT_SIZE + " bytes");
}
validateStorageJsonShape(bytes);
final AgentVersionContent content;
try {
content = JacksonUtils.toObj(bytes, AgentVersionContent.class);
} catch (NacosDeserializationException e) {
throw new IllegalArgumentException("Invalid AgentVersionContent", e);
}
validate(content);
return content;
}
private static void validate(AgentVersionContent content) {
if (content == null) {
throw new IllegalArgumentException("AgentVersionContent must not be null");
}
if (!AgentVersionContent.KIND.equals(content.getKind())) {
throw new IllegalArgumentException("AgentVersionContent kind must be "
+ AgentVersionContent.KIND);
}
if (!Integer.valueOf(AgentVersionContent.SCHEMA_VERSION)
.equals(content.getSchemaVersion())) {
throw new IllegalArgumentException("AgentVersionContent schemaVersion must be "
+ AgentVersionContent.SCHEMA_VERSION);
}
List<AgentCallInterface> callInterfaces = content.getCallInterfaces();
if (callInterfaces == null || callInterfaces.isEmpty()
|| callInterfaces.size() > MAX_CALL_INTERFACES) {
throw new IllegalArgumentException(
"AgentVersionContent callInterfaces must contain 1 to " + MAX_CALL_INTERFACES
+ " items");
}
Set<String> protocols = new HashSet<String>();
for (AgentCallInterface callInterface : callInterfaces) {
AgentModelValidator.validateCallInterface(callInterface);
if (!protocols.add(callInterface.getProtocol())) {View on GitHub (pinned to 9b989acdf1)
Solutions
- Use new AgentVersionContent(callInterfaces) which sets kind and schemaVersion automatically.
- If setting fields manually, call content.setKind(AgentVersionContent.KIND).
- Ensure the JSON you deserialize was produced by this serializer's serialize method.
Example fix
// before AgentVersionContent c = new AgentVersionContent(); c.setCallInterfaces(ifaces); // after AgentVersionContent c = new AgentVersionContent(ifaces); // sets kind + schemaVersion
Defensive patterns
Strategy: validation
Validate before calling
AgentVersionContent c = new AgentVersionContent(callInterfaces); // sets kind automatically // or manually: c.setKind(AgentVersionContent.KIND);
Prevention
- Use the parameterized constructor which sets kind and schemaVersion.
- Avoid the default constructor unless you set all discriminator fields.
When it happens
Trigger: Serializing or deserializing content whose kind field is missing, null, or set to a different string. This happens when content is built manually without setting kind, or when a JSON document from a different schema is loaded.
Common situations: Manually constructing AgentVersionContent without using the constructor that sets kind (the default constructor leaves kind null), or loading a JSON blob intended for a different resource type.
Related errors
- AgentVersionContent bytes must not be null
- AgentVersionContent must not be null
- AgentVersionContent schemaVersion must be {AgentVersionConte
- AgentVersionContent callInterfaces must contain 1 to {MAX_CA
- Duplicate CallInterface protocol: {callInterface.getProtocol
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/34f70179429606dd.
Report an issue: GitHub.