apache/cassandra · error · IllegalArgumentException
Invalid data storage: %s Accepted units:%s
Error message
Invalid data storage: %s Accepted units:%s
What it means
validateMinUnit checks that the unit parsed from a DataStorageSpec value is not smaller than the required minimum unit for that spec subclass. If the source unit compares below the min unit (ordinal-wise), it throws this IllegalArgumentException listing only the acceptable units.
Source
Thrown at src/java/org/apache/cassandra/config/DataStorageSpec.java:89
else
{
throw new IllegalArgumentException("Invalid data storage: " + value + " Accepted units:" + acceptedUnits(minUnit) +
" where case matters and only non-negative values are accepted");
}
}
private DataStorageSpec(String value, DataStorageUnit minUnit, long max)
{
this(value, minUnit);
validateMinUnit(unit, minUnit, value);
validateQuantity(value, quantity(), unit(), minUnit, max);
}
private static void validateMinUnit(DataStorageUnit sourceUnit, DataStorageUnit minUnit, String value)
{
if (sourceUnit.compareTo(minUnit) < 0)
throw new IllegalArgumentException(String.format("Invalid data storage: %s Accepted units:%s", value, acceptedUnits(minUnit)));
}
private static String acceptedUnits(DataStorageUnit minUnit)
{
DataStorageUnit[] units = DataStorageUnit.values();
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)View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Express the value in a unit at or above the min unit (e.g. convert 512KiB to 1MiB if the min unit is MiB)
- Read acceptedUnits from the message and pick the smallest listed unit
- Use the numeric double-based constructor with an explicit unit when you control the unit programmatically
- Add a pre-parse check comparing DataStorageUnit ordinals against the bound's minimum
Example fix
// before
DataStorageSpec.LongStorageBound b = new DataStorageSpec.LongStorageBound("512KiB");
// after
DataStorageSpec.LongStorageBound b = new DataStorageSpec.LongStorageBound("1MiB"); Defensive patterns
Strategy: validation
Validate before calling
DataStorageSpec.DataStorageUnit src = DataStorageSpec.DataStorageUnit.fromSymbol(unitToken);
if (src.compareTo(MIN_UNIT) < 0)
throw new IllegalArgumentException("Unit " + unitToken + " is below the minimum " + MIN_UNIT); Try / catch
try {
bound = new DataStorageSpec.LongStorageBound(value);
} catch (IllegalArgumentException e) {
logger.error("Storage unit below required minimum for bound: " + value, e);
bound = new DataStorageSpec.LongStorageBound(convertToMinUnitOrAbove(value));
} Prevention
- Check each bound subclass's minimum unit before formatting its value
- Convert small-unit values (B, KiB) up to the minimum unit programmatically
- Prefer the numeric constructors with explicit units in code
When it happens
Trigger: Constructing a bounded/extended DataStorageSpec (e.g. DataStorageSpec.LongStorageBound) from a string expressed in a unit below the required min unit, such as '512B' or '10KiB' where the bound requires MiB or larger.
Common situations: Programmatic config building where subclasses impose minimum units; YAML migration code reusing a generic storage string for a bound type that needs a larger unit; test fixtures with tiny values.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Invalid data rate: ${value} Accepted units: MiB/s, KiB/s, B/
- Invalid data rate: value must be non-negative
- Unsupported data rate unit: %s. Supported units are: %s
- Invalid data storage: ${value} Accepted units:${acceptedUnit
- Invalid value of entire_sstable_stream_throughput_outbound:
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/e82c8e5b2898a7be.
Report an issue: GitHub.