{"record":{"id":"8eaf0df9bf17ef13","repo":"alibaba/nacos","slug":"agentversioncontent-json-must-not-be-empty","errorCode":null,"errorMessage":"AgentVersionContent JSON must not be empty","messagePattern":"AgentVersionContent JSON must not be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java","lineNumber":274,"sourceCode":"            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) {\n                    rejectUnknownFields((Map<?, ?>) endpoint, ENDPOINT_FIELDS,\n                        \"DeclaredEndpoint\");\n                }\n            }\n        }\n    }\n    \n    private static void validateSingleJsonValue(byte[] bytes) {\n        try (JsonParser parser = STRICT_JSON_FACTORY.createParser(bytes)) {\n            if (parser.nextToken() == null) {\n                throw new IllegalArgumentException(\"AgentVersionContent JSON must not be empty\");\n            }\n            parser.skipChildren();\n            if (parser.nextToken() != null) {\n                throw new IllegalArgumentException(\n                    \"AgentVersionContent must contain one JSON value\");\n            }\n        } catch (IOException e) {\n            throw new IllegalArgumentException(\"Invalid AgentVersionContent\", e);\n        }\n    }\n    \n    private static void rejectUnknownFields(Map<?, ?> value, Set<String> fields,\n        String objectName) {\n        for (Object field : value.keySet()) {\n            if (!fields.contains(field)) {\n                throw new IllegalArgumentException(\"Unknown \" + objectName + \" field: \" + field);\n            }\n        }","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java#L256-L292","documentation":"Thrown by validateSingleJsonValue when the JSON parser yields no tokens at all — the byte array is empty or contains only whitespace/comments that produce zero JSON tokens. Persisted content must be a non-empty JSON value.","triggerScenarios":"Deserializing a zero-length byte array, or bytes containing only whitespace. The strict Jackson parser's first nextToken() returns null.","commonSituations":"A storage cell was written empty, or a truncation left zero bytes. Also in tests passing new byte[0].","solutions":["Ensure content is always serialized through serialize() which produces non-empty JSON.","Restore or re-publish the version if the stored bytes are empty.","Guard empty bytes before calling deserialize."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (bytes == null || bytes.length == 0) {\n    throw new NacosException(NacosException.SERVER_ERROR, \"empty content bytes\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard empty bytes before deserialize.","Ensure write paths never persist empty cells."],"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"}