apache/cassandra · error · IllegalArgumentException
Invalid data storage: %d %s. It shouldn't be more than %d in
Error message
Invalid data storage: %d %s. It shouldn't be more than %d in %s
What it means
This is the long-constructor variant of the max-bound check in DataStorageSpec.validateQuantity: when the quantity converted to the spec's minimum unit reaches the maximum bound, an IllegalArgumentException is thrown with a formatted message showing the value, source unit, and allowed maximum.
Source
Thrown at src/java/org/apache/cassandra/config/DataStorageSpec.java:113
return Arrays.toString(Arrays.copyOfRange(units, minUnit.ordinal(), units.length));
}
private static void validateQuantity(String value, long quantity, DataStorageUnit sourceUnit, DataStorageUnit minUnit, long max)
{
// no need to validate for negatives as they are not allowed at first place from the regex
if (minUnit.convert(quantity, sourceUnit) >= max)
throw new IllegalArgumentException("Invalid data storage: " + value + ". It shouldn't be more than " +
(max - 1) + " in " + toLowerCaseLocalized(minUnit.name()));
}
private static void validateQuantity(long quantity, DataStorageUnit sourceUnit, DataStorageUnit minUnit, long max)
{
if (quantity < 0)
throw new IllegalArgumentException("Invalid data storage: value must be non-negative");
if (minUnit.convert(quantity, sourceUnit) >= max)
throw new IllegalArgumentException(String.format("Invalid data storage: %d %s. It shouldn't be more than %d in %s",
quantity, toLowerCaseLocalized(sourceUnit.name()),
max - 1, toLowerCaseLocalized(minUnit.name())));
}
// get vs no-get prefix is not consistent in the code base, but for classes involved with config parsing, it is
// imporant to be explicit about get/set as this changes how parsing is done; this class is a data-type, so is
// not nested, having get/set can confuse parsing thinking this is a nested type
/**
* @return the data storage quantity.
*/
public long quantity()
{
return quantity;
}
/**
* @return the data storage unit.
*/View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pass a value below the documented maximum for the setting
- Replace Long.MAX_VALUE sentinels with a realistic bounded size
- If the value is computed, check the intermediate math for overflow
Example fix
// before new DataStorageSpec.DataStorageBytesBound(Long.MAX_VALUE) // after new DataStorageSpec.DataStorageBytesBound(Long.MAX_VALUE - 1)
Defensive patterns
Strategy: validation
Validate before calling
if (quantity == Long.MAX_VALUE || quantity < 0) throw new IllegalArgumentException("quantity out of representable range"); Try / catch
try { spec = new DataStorageSpec.DataStorageBytesBound(v); } catch (IllegalArgumentException e) { spec = defaultSpec; } Prevention
- Never pass Long.MAX_VALUE as a 'max' storage size
- Add range assertions before constructing specs from computed values
- Test config builders with boundary values
When it happens
Trigger: Calling a DataStorageSpec long constructor with a quantity whose normalized value (in minUnit) is >= max, e.g. new DataStorageSpec.DataStorageBytesBound(Long.MAX_VALUE) — which is the MAX bound itself and thus rejected.
Common situations: Programmatic config builders that pass Long.MAX_VALUE as 'unlimited', size arithmetic overflow, or tests using extreme sentinel values.
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
- Invalid data storage: ${value}. It shouldn't be more than ${
- Invalid data storage: value must be non-negative
- Unsupported data storage unit: %s. Supported units are: %s
- Configured ${configName} "${intf}" could not be found
- Configured ${configName} "${intf}" was found, but had no add
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/851f113308998f36.
Report an issue: GitHub.