{"record":{"id":"3bac57f0e544b10f","repo":"alibaba/nacos","slug":"agentversioncontent-must-contain-one-json-value","errorCode":null,"errorMessage":"AgentVersionContent must contain one JSON value","messagePattern":"AgentVersionContent must contain one JSON value","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java","lineNumber":278,"sourceCode":"                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        }\n    }\n    \n    /**\n     * Immutable persisted bytes, digest and byte count for one Agent Version content object.","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java#L260-L296","documentation":"Thrown by validateSingleJsonValue when the byte array contains more than one top-level JSON value (e.g. two concatenated JSON objects). Persisted content must be exactly one JSON value to prevent ambiguity in digest and storage.","triggerScenarios":"Deserializing bytes like '{...}{...}' or '{...}123'. After skipping the first value's children, nextToken() is non-null, indicating trailing content.","commonSituations":"Two JSON documents were concatenated into one storage cell, or a buffering bug appended partial writes. The strict duplicate-detection factory also helps catch structural issues.","solutions":["Ensure exactly one JSON value is written per storage key.","Re-publish the version to overwrite the concatenated bytes with a single canonical document.","Audit the storage provider for write atomicity."],"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(\"one JSON value\")) {\n        throw corruptedContent(\"multiple JSON values in one content cell\", e);\n    }\n    throw e;\n}","preventionTips":["Write exactly one JSON value per storage key.","Audit storage provider for atomic single-value writes."],"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"}