{"record":{"id":"e581ab2a27764874","repo":"alibaba/nacos","slug":"agentversioncontent-bytes-must-not-be-null","errorCode":null,"errorMessage":"AgentVersionContent bytes must not be null","messagePattern":"AgentVersionContent bytes 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":107,"sourceCode":"            throw new IllegalArgumentException(\"Unable to serialize AgentVersionContent\", e);\n        }\n        if (bytes.length > MAX_CONTENT_SIZE) {\n            throw new IllegalArgumentException(\n                \"AgentVersionContent exceeds \" + MAX_CONTENT_SIZE + \" bytes\");\n        }\n        return new SerializedContent(bytes, digest(bytes));\n    }\n    \n    /**\n     * Compute the digest of the exact bytes read from or written to AI Storage.\n     *\n     * @param bytes persisted Agent Version content bytes\n     * @return digest token in {@code sha256:<lowercase hex>} form\n     * @throws IllegalArgumentException when bytes are null or exceed the storage limit\n     */\n    public static String digest(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        return DIGEST_PREFIX + sha256Hex(bytes);\n    }\n    \n    /**\n     * Deserialize Agent Version bytes and verify the storage model.\n     *\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\");","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java#L89-L125","documentation":"Thrown by AgentVersionContentSerializer.digest when the bytes argument is null. The digest method computes the SHA-256 of exact persisted bytes and is used to verify integrity on read; null bytes cannot be digested.","triggerScenarios":"Calling AgentVersionContentSerializer.digest(null) directly, or passing a byte array reference that resolved to null — e.g. a storage provider returning null which was not guarded before calling digest.","commonSituations":"Internal code path where the storage get() returned null but the null check was skipped, or a test/utility computing a digest on an uninitialized byte array.","solutions":["Guard the byte array for null before calling digest.","Ensure the storage provider's get() never returns null unguarded — the load() path in AgentVersionStorageService already checks bytes == null and throws corruptedContent before reaching digest."],"exampleFix":"// before\nString d = AgentVersionContentSerializer.digest(maybeNullBytes);\n\n// after\nif (bytes == null) {\n    throw new NacosException(NacosException.SERVER_ERROR, \"content bytes missing\");\n}\nString d = AgentVersionContentSerializer.digest(bytes);","handlingStrategy":"validation","validationCode":"java.util.Objects.requireNonNull(bytes, \"content bytes\");\nString d = AgentVersionContentSerializer.digest(bytes);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always null-check bytes from storage providers before digest.","Route through AgentVersionStorageService.load which guards null bytes."],"tags":["validation","agent-version","digest","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}