{"record":{"id":"70285be1b30b7d6b","repo":"alibaba/nacos","slug":"invalid-agentversioncontent","errorCode":null,"errorMessage":"Invalid AgentVersionContent","messagePattern":"Invalid AgentVersionContent","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java","lineNumber":136,"sourceCode":"     *\n     * @param bytes persisted Agent Version content bytes\n     * @return deserialized content\n     * @throws IllegalArgumentException when bytes are invalid or out of contract\n     */\n    public static AgentVersionContent deserialize(byte[] bytes) {\n        if (bytes == null) {\n            throw new IllegalArgumentException(\"AgentVersionContent bytes must not be null\");\n        }\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        }","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java#L118-L154","documentation":"Thrown by AgentVersionContentSerializer.deserialize when Jackson cannot parse the bytes into an AgentVersionContent (NacosDeserializationException), after the bytes passed shape validation. The raw JSON is structurally a single value and an object, but field-level JSON decoding fails.","triggerScenarios":"Persisted bytes are valid JSON and a single object but contain a field whose value type cannot be bound to the AgentVersionContent model — e.g. callInterfaces is a JSON string instead of an array, or schemaVersion is a non-integer.","commonSituations":"Content was hand-edited or written by a non-conforming client, or a schema migration left a field with an unexpected type. The shape check (validateStorageJsonShape) permits the top-level structure but Jackson binding to typed fields fails.","solutions":["Inspect the cause NacosDeserializationException for the offending field and value type.","Re-publish the version with a conforming AgentVersionContent built through the API/SDK.","If migrating schema, ensure the writer and reader agree on field types."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return AgentVersionContentSerializer.deserialize(bytes);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Invalid AgentVersionContent\")\n        && e.getCause() instanceof NacosDeserializationException) {\n        throw corruptedContent(\"Agent Version content JSON binding failed\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Only deserialize bytes produced by this serializer.","Keep writer and reader on the same schemaVersion.","Unit-test round-trip serialize/deserialize for every content shape."],"tags":["deserialization","agent-version","storage-integrity","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}