{"record":{"id":"42413d6f845d1878","repo":"alibaba/nacos","slug":"agentversioncontent-must-be-a-json-object","errorCode":null,"errorMessage":"AgentVersionContent must be a JSON object","messagePattern":"AgentVersionContent must be a JSON object","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java","lineNumber":245,"sourceCode":"        char[] encoded = new char[digest.length * 2];\n        for (int i = 0; i < digest.length; i++) {\n            int value = digest[i] & 0xFF;\n            encoded[i * 2] = HEX[value >>> 4];\n            encoded[i * 2 + 1] = HEX[value & 0x0F];\n        }\n        return new String(encoded);\n    }\n    \n    private static void validateStorageJsonShape(byte[] bytes) {\n        validateSingleJsonValue(bytes);\n        final Map<?, ?> root;\n        try {\n            root = JacksonUtils.toObj(bytes, Map.class);\n        } catch (NacosDeserializationException e) {\n            throw new IllegalArgumentException(\"Invalid AgentVersionContent\", e);\n        }\n        if (root == null) {\n            throw new IllegalArgumentException(\"AgentVersionContent must be a JSON object\");\n        }\n        rejectUnknownFields(root, CONTENT_FIELDS, \"AgentVersionContent\");\n        Object callInterfaces = root.get(\"callInterfaces\");\n        if (!(callInterfaces instanceof List)) {\n            return;\n        }\n        for (Object callInterface : (List<?>) callInterfaces) {\n            if (!(callInterface instanceof Map)) {\n                continue;\n            }\n            Map<?, ?> interfaceObject = (Map<?, ?>) callInterface;\n            rejectUnknownFields(interfaceObject, CALL_INTERFACE_FIELDS, \"AgentCallInterface\");\n            Object endpoints = interfaceObject.get(\"declaredEndpoints\");\n            if (!(endpoints instanceof List)) {\n                continue;\n            }\n            for (Object endpoint : (List<?>) endpoints) {\n                if (endpoint instanceof Map) {","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java#L227-L263","documentation":"Thrown by validateStorageJsonShape when the parsed JSON root is null (i.e. the JSON literal 'null'). The storage projection must be a JSON object, not a null value.","triggerScenarios":"Deserializing bytes whose content is the JSON token sequence representing null. validateSingleJsonValue passes (one value) but Map binding yields null, which is rejected here.","commonSituations":"A storage cell contains the literal string 'null', or a writer erroneously serialized a null reference. Indicates a logic error in the write path.","solutions":["Re-publish the version; content should never be persisted as JSON null.","Audit the write path that produced the 'null' bytes — it likely serialized a null AgentVersionContent."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return AgentVersionContentSerializer.deserialize(bytes);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"must be a JSON object\")) {\n        throw corruptedContent(\"stored content is JSON null\", e);\n    }\n    throw e;\n}","preventionTips":["Never persist JSON null as content.","Re-publish versions whose storage cell contains 'null'."],"tags":["deserialization","agent-version","json","storage-integrity","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}