{"record":{"id":"440342d86d03de5e","repo":"alibaba/nacos","slug":"agentversioncontent-schemaversion-must-be-agentve","errorCode":null,"errorMessage":"AgentVersionContent schemaVersion must be {AgentVersionContent.SCHEMA_VERSION}","messagePattern":"AgentVersionContent schemaVersion must be (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java","lineNumber":152,"sourceCode":"            content = JacksonUtils.toObj(bytes, AgentVersionContent.class);\n        } catch (NacosDeserializationException e) {\n            throw new IllegalArgumentException(\"Invalid AgentVersionContent\", e);\n        }\n        validate(content);\n        return content;\n    }\n    \n    private static void validate(AgentVersionContent content) {\n        if (content == null) {\n            throw new IllegalArgumentException(\"AgentVersionContent must not be null\");\n        }\n        if (!AgentVersionContent.KIND.equals(content.getKind())) {\n            throw new IllegalArgumentException(\"AgentVersionContent kind must be \"\n                + AgentVersionContent.KIND);\n        }\n        if (!Integer.valueOf(AgentVersionContent.SCHEMA_VERSION)\n            .equals(content.getSchemaVersion())) {\n            throw new IllegalArgumentException(\"AgentVersionContent schemaVersion must be \"\n                + AgentVersionContent.SCHEMA_VERSION);\n        }\n        List<AgentCallInterface> callInterfaces = content.getCallInterfaces();\n        if (callInterfaces == null || callInterfaces.isEmpty()\n            || callInterfaces.size() > MAX_CALL_INTERFACES) {\n            throw new IllegalArgumentException(\n                \"AgentVersionContent callInterfaces must contain 1 to \" + MAX_CALL_INTERFACES\n                    + \" items\");\n        }\n        Set<String> protocols = new HashSet<String>();\n        for (AgentCallInterface callInterface : callInterfaces) {\n            AgentModelValidator.validateCallInterface(callInterface);\n            if (!protocols.add(callInterface.getProtocol())) {\n                throw new IllegalArgumentException(\n                    \"Duplicate CallInterface protocol: \" + callInterface.getProtocol());\n            }\n        }\n    }","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java#L134-L170","documentation":"Thrown by validate when content.getSchemaVersion() does not equal the constant AgentVersionContent.SCHEMA_VERSION (1). The schemaVersion guards against reading content written by an incompatible future or past storage schema.","triggerScenarios":"Serializing/deserializing content whose schemaVersion is null or an integer other than 1. Occurs when content is built manually without schemaVersion, or when persisted bytes were written by a different schema version of the serializer.","commonSituations":"Manual construction with the default constructor (schemaVersion stays null), or a version skew between a writer using a newer schema and a reader expecting schemaVersion 1.","solutions":["Use new AgentVersionContent(callInterfaces) which sets schemaVersion to SCHEMA_VERSION.","If upgrading the storage schema, increment SCHEMA_VERSION and provide a migration path; do not mix versions.","For manual construction, call content.setSchemaVersion(AgentVersionContent.SCHEMA_VERSION)."],"exampleFix":"// before\nAgentVersionContent c = new AgentVersionContent();\nc.setCallInterfaces(ifaces);\n\n// after\nAgentVersionContent c = new AgentVersionContent(ifaces); // sets schemaVersion=1","handlingStrategy":"validation","validationCode":"AgentVersionContent c = new AgentVersionContent(callInterfaces); // sets schemaVersion=1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the parameterized constructor for correct schemaVersion.","When changing the storage schema, bump SCHEMA_VERSION and migrate."],"tags":["validation","agent-version","schema-version","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}