{"record":{"id":"4b0bb43d3e1d9983","repo":"alibaba/nacos","slug":"agentversioncontent-must-not-be-null","errorCode":null,"errorMessage":"AgentVersionContent must not be null","messagePattern":"AgentVersionContent must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java","lineNumber":144,"sourceCode":"        }\n        if (bytes.length > MAX_CONTENT_SIZE) {\n            throw new IllegalArgumentException(\n                \"AgentVersionContent exceeds \" + MAX_CONTENT_SIZE + \" bytes\");\n        }\n        validateStorageJsonShape(bytes);\n        final AgentVersionContent content;\n        try {\n            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>();","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java#L126-L162","documentation":"Thrown by the private validate method when the deserialized AgentVersionContent object is null. After Jackson binding, a null result means the JSON was literally 'null' or binding produced no object; this is treated as invalid content.","triggerScenarios":"Deserializing bytes whose JSON value is null, or a binding path that yields null. validateStorageJsonShape would normally reject a literal null root earlier (root == null -> 'must be a JSON object'), so reaching here implies validate is called from serialize with a null content argument.","commonSituations":"Calling serialize(null) — the validate(content) at the top of serialize forwards null here. A caller forgot to construct the content object.","solutions":["Ensure you pass a non-null AgentVersionContent to serialize.","Construct content via new AgentVersionContent(callInterfaces) or the builder used by the SDK."],"exampleFix":"// before\nSerializedContent s = AgentVersionContentSerializer.serialize(null);\n\n// after\nAgentVersionContent content = new AgentVersionContent(callInterfaces);\nSerializedContent s = AgentVersionContentSerializer.serialize(content);","handlingStrategy":"validation","validationCode":"java.util.Objects.requireNonNull(content, \"AgentVersionContent\");\nSerializedContent sc = AgentVersionContentSerializer.serialize(content);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass null to serialize.","Construct content via new AgentVersionContent(callInterfaces)."],"tags":["validation","agent-version","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}