apache/cassandra · error · IllegalArgumentException
The length of the provided dictionary array (<dict.length>)…
Error message
The length of the provided dictionary array (<dict.length>) is not equal to provided length value (<dictLength>).
What it means
validate() cross-checks that the declared dictLength equals dict.length. A mismatch means the descriptor's metadata disagrees with the actual payload, which would corrupt the import checksum and storage, so it is rejected with both lengths in the message.
Solutions
- Pass dict.length as dictLength so both match the actual payload
- Re-read the dictionary file completely and regenerate the descriptor from the same buffer
- If metadata says otherwise, investigate why the file is truncated or corrupted instead of forcing the length
Example fix
// before new CompressionDictionaryDataObject(..., dict, headerDeclaredLength, ...); // after new CompressionDictionaryDataObject(..., dict, dict.length, ...);
Defensive patterns
Strategy: validation
Validate before calling
if (obj.dict == null || obj.dictLength != obj.dict.length) throw new IllegalArgumentException("dictLength (" + obj.dictLength + ") must equal dict.length (" + (obj.dict == null ? -1 : obj.dict.length) + ")"); Type guard
boolean lengthsConsistent(CompressionDictionaryDataObject o) { return o.dict != null && o.dictLength == o.dict.length; } Try / catch
try { tabularData.fromDataObject(obj); } catch (IllegalArgumentException e) { if (e.getMessage().contains("not equal to provided length value")) { /* rebuild with dictLength = dict.length */ } else throw e; } Prevention
- Never pass a separately-sourced length and payload; use dict.length
- If length must be carried from metadata, verify it against the buffer before import
- Watch for truncated reads that shrink the array but not the declared length
When it happens
Trigger: Constructing CompressionDictionaryDataObject where dictLength != dict.length — e.g. the length came from stale metadata while the byte array was re-read/truncated, or the caller passed a partial buffer with the original length.
Common situations: Truncated dictionary files whose header still declares the original size; off-by-one or unit errors (chars vs bytes) when computing length; mixing descriptors and payloads from different dictionary versions.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Keyspace not specified.
- Provided dictionary byte array is null or empty.
- Provided dictionary id must be positive but it is
- Provided kind is null.
- Size has to be strictly positive number, it is
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/27c2d8a29819c552.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/db/compression/CompressionDictionaryDetailsTabularData.java:314
throw new IllegalArgumentException("Provided dictionary byte array is null or empty.");
if (kind == null)
throw new IllegalArgumentException("Provided kind is null.");
CompressionDictionary.Kind dictionaryKind;
try
{
dictionaryKind = CompressionDictionary.Kind.valueOf(kind);
}
catch (IllegalArgumentException ex)
{
throw new IllegalArgumentException("There is no such dictionary kind like '" + kind + "'. Available kinds: " + Arrays.asList(CompressionDictionary.Kind.values()));
}
if (dictLength <= 0)
throw new IllegalArgumentException("Size has to be strictly positive number, it is '" + dictLength + "'.");
if (dict.length != dictLength)
throw new IllegalArgumentException("The length of the provided dictionary array (" + dict.length + ") is not equal to provided length value (" + dictLength + ").");
if (createdAt == null)
throw new IllegalArgumentException("The creation date not specified.");
int checksumOfDictionaryToImport = CompressionDictionary.calculateChecksum((byte) dictionaryKind.ordinal(), dictId, dict);
if (checksumOfDictionaryToImport != dictChecksum)
{
throw new IllegalArgumentException(format("Computed checksum of dictionary to import (%s) is different from checksum specified on input (%s).",
checksumOfDictionaryToImport,
dictChecksum));
}
}
}
}
View on GitHub (pinned to 88fd0f6a0e)