alibaba/nacos · error · IllegalArgumentException
AgentVersionContent bytes must not be null
Error message
AgentVersionContent bytes must not be null
What it means
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.
Source
Thrown at ai/src/main/java/com/alibaba/nacos/ai/service/agent/storage/AgentVersionContentSerializer.java:107
throw new IllegalArgumentException("Unable to serialize AgentVersionContent", e);
}
if (bytes.length > MAX_CONTENT_SIZE) {
throw new IllegalArgumentException(
"AgentVersionContent exceeds " + MAX_CONTENT_SIZE + " bytes");
}
return new SerializedContent(bytes, digest(bytes));
}
/**
* Compute the digest of the exact bytes read from or written to AI Storage.
*
* @param bytes persisted Agent Version content bytes
* @return digest token in {@code sha256:<lowercase hex>} form
* @throws IllegalArgumentException when bytes are null or exceed the storage limit
*/
public static String digest(byte[] bytes) {
if (bytes == null) {
throw new IllegalArgumentException("AgentVersionContent bytes must not be null");
}
if (bytes.length > MAX_CONTENT_SIZE) {
throw new IllegalArgumentException(
"AgentVersionContent exceeds " + MAX_CONTENT_SIZE + " bytes");
}
return DIGEST_PREFIX + sha256Hex(bytes);
}
/**
* Deserialize Agent Version bytes and verify the storage model.
*
* @param bytes persisted Agent Version content bytes
* @return deserialized content
* @throws IllegalArgumentException when bytes are invalid or out of contract
*/
public static AgentVersionContent deserialize(byte[] bytes) {
if (bytes == null) {
throw new IllegalArgumentException("AgentVersionContent bytes must not be null");View on GitHub (pinned to 9b989acdf1)
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.
Example fix
// before
String d = AgentVersionContentSerializer.digest(maybeNullBytes);
// after
if (bytes == null) {
throw new NacosException(NacosException.SERVER_ERROR, "content bytes missing");
}
String d = AgentVersionContentSerializer.digest(bytes); Defensive patterns
Strategy: validation
Validate before calling
java.util.Objects.requireNonNull(bytes, "content bytes"); String d = AgentVersionContentSerializer.digest(bytes);
Prevention
- Always null-check bytes from storage providers before digest.
- Route through AgentVersionStorageService.load which guards null bytes.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- AgentVersionContent must not be null
- AgentVersionContent kind must be {AgentVersionContent.KIND}
- AgentVersionContent schemaVersion must be {AgentVersionConte
- AgentVersionContent callInterfaces must contain 1 to {MAX_CA
- Duplicate CallInterface protocol: {callInterface.getProtocol
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/e581ab2a27764874.
Report an issue: GitHub.