apache/cassandra · error · IllegalArgumentException

Unsupported data storage unit: %s. Supported units are: %s

Error message

Unsupported data storage unit: %s. Supported units are: %s

What it means

DataStorageSpec parses storage values as number + unit symbol (B, KiB, MiB, GiB, TiB, PB etc.). fromSymbol throws this IllegalArgumentException when the unit suffix in the string does not match any known DataStorageUnit symbol, listing all supported symbols.

Source

Thrown at src/java/org/apache/cassandra/config/DataStorageSpec.java:648

            assert (over > 0) && (over < (MAX-1L)) && (over == (MAX / m));

            if (d > over)
                return Long.MAX_VALUE;
            return Math.multiplyExact(d, m);
        }

        /**
         * @param symbol the unit symbol
         * @return the memory unit corresponding to the given symbol
         */
        public static DataStorageUnit fromSymbol(String symbol)
        {
            for (DataStorageUnit value : values())
            {
                if (value.symbol.equalsIgnoreCase(symbol))
                    return value;
            }
            throw new IllegalArgumentException(String.format("Unsupported data storage unit: %s. Supported units are: %s",
                                                           symbol, Arrays.stream(values())
                                                                         .map(u -> u.symbol)
                                                                         .collect(Collectors.joining(", "))));
        }

        static final long MAX = Long.MAX_VALUE;

        /**
         * The unit symbol
         */
        private final String symbol;

        DataStorageUnit(String symbol)
        {
            this.symbol = symbol;
        }

        public String getSymbol()

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Use the exact supported symbols shown in the error message (e.g. KiB, MiB, GiB)
  2. Replace decimal-style units: MB -> MiB, KB -> KiB
  3. Fix typos in the unit suffix in cassandra.yaml

Example fix

// before (cassandra.yaml)
commitlog_total_space_in_mb: 512MB
// after
commitlog_total_space: 512MiB
Defensive patterns

Strategy: validation

Validate before calling

String UNIT_RE = "^(B|KiB|MiB|GiB|TiB|PiB)$"; if (!unit.matches(UNIT_RE)) throw new IllegalArgumentException("unsupported unit: " + unit);

Try / catch

try { DataStorageSpec.parse("512MiB"); } catch (IllegalArgumentException e) { /* show supported units from e.getMessage() */ }

Prevention

When it happens

Trigger: Parsing a config value like '100 MB' or '10 kilobytes' or '512kb' (case is handled, but the symbol must exist), or calling DataStorageSpec.DataStorageUnit.fromSymbol("KB") directly with an unrecognized symbol.

Common situations: Using decimal symbols (KB, MB) instead of the binary ones Cassandra expects (KiB, MiB), misspelling units (Mib, Gb), or copying configs from tools that use different unit conventions.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/0cfa2e6bdfe54a46. Report an issue: GitHub.