apache/cassandra · error · IllegalArgumentException
Size has to be strictly positive number, it is
Error message
Size has to be strictly positive number, it is '<dictLength>'.
What it means
The declared dictionary length (dictLength) must be a strictly positive number. validate() rejects dictLength <= 0 before comparing it to the actual byte array length, ensuring the descriptor always declares a meaningful payload size.
Solutions
- Set dictLength to the actual number of bytes in the dictionary payload (dict.length)
- If reading from a file, use the file size after verifying it is non-empty
- Initialize the length field rather than leaving it at its numeric default
Example fix
// before int dictLength = 0; // unset // after int dictLength = dict.length;
Defensive patterns
Strategy: validation
Validate before calling
if (obj.dictLength <= 0) throw new IllegalArgumentException("dictLength must be positive, got: " + obj.dictLength); Type guard
boolean hasPositiveLength(CompressionDictionaryDataObject o) { return o.dictLength > 0; } Try / catch
try { tabularData.fromDataObject(obj); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Size has to be strictly positive")) { /* set dictLength = dict.length and rebuild */ } else throw e; } Prevention
- Derive dictLength directly from dict.length so it can never default to 0
- Avoid unset numeric defaults; compute lengths at construction time
- Check the payload was actually loaded before declaring its length
When it happens
Trigger: Constructing a CompressionDictionaryDataObject with dictLength = 0 or negative — typically an unset numeric field (default 0) or a length variable computed from an empty/failed read.
Common situations: Import tooling where the length field defaulted to 0; lengths parsed from a truncated metadata source; callers passing byte count of an empty buffer.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 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.
- Table not specified.
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/d269782431da1efa.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/db/compression/CompressionDictionaryDetailsTabularData.java:312
throw new IllegalArgumentException("Provided dictionary id must be positive but it is '" + dictId + "'.");
if (dict == null || dict.length == 0)
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)