apache/cassandra · warning · IllegalArgumentException
value %s is not a valid human-readable file size
Error message
value %s is not a valid human-readable file size
What it means
parseFileSize(String) throws IllegalArgumentException when the input does not match the pattern '\d+(\.\d+)? (GiB|KiB|MiB|TiB|bytes)' — a number, one space, and one of the exact binary units. The format is strict: no 'KB'/'GB' decimal units, no missing space, no bare numbers.
Source
Thrown at src/java/org/apache/cassandra/io/util/FileUtils.java:332
}
public static String getCanonicalPath(File file)
{
return file.canonicalPath();
}
/** Return true if file is contained in folder */
public static boolean isContained(File folder, File file)
{
return folder.isAncestorOf(file);
}
public static long parseFileSize(String value)
{
long result;
if (!value.matches("\\d+(\\.\\d+)? (GiB|KiB|MiB|TiB|bytes)"))
{
throw new IllegalArgumentException(
String.format("value %s is not a valid human-readable file size", value));
}
if (value.endsWith(" TiB"))
{
result = Math.round(Double.valueOf(value.replace(" TiB", "")) * ONE_TIB);
return result;
}
else if (value.endsWith(" GiB"))
{
result = Math.round(Double.valueOf(value.replace(" GiB", "")) * ONE_GIB);
return result;
}
else if (value.endsWith(" KiB"))
{
result = Math.round(Double.valueOf(value.replace(" KiB", "")) * ONE_KIB);
return result;
}
else if (value.endsWith(" MiB"))View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Format the value as '<number> <UNIT>' with a single space and unit in {bytes, KiB, MiB, GiB, TiB}.
- Convert decimal units (MB→MiB etc.) or rewrite as raw byte counts elsewhere.
- Pre-parse/validate with the same regex before calling.
Example fix
// before
FileUtils.parseFileSize("10MB"); // throws
// after
FileUtils.parseFileSize("10 MiB"); // OK Defensive patterns
Strategy: validation
Validate before calling
private static final Pattern SIZE = Pattern.compile("\\d+(\\.\\d+)? (GiB|KiB|MiB|TiB|bytes)");
boolean isValidSize(String v) { return v != null && SIZE.matcher(v).matches(); } Type guard
boolean isHumanReadableSize(String v) { return v != null && v.matches("\\d+(\\.\\d+)? (GiB|KiB|MiB|TiB|bytes)"); } Try / catch
try { long n = FileUtils.parseFileSize(v); } catch (IllegalArgumentException e) { /* normalize unit and retry */ } Prevention
- Always emit sizes as '<number> <binary unit>' with exactly one space.
- Convert MB/GB (decimal) to MiB/GiB before parsing.
- Centralize size-string formatting in one utility.
When it happens
Trigger: Calling FileUtils.parseFileSize with values like '10MB', '10 MB', '1024', '1.5 GiB ' (trailing space), or lowercase 'mib'.
Common situations: Users writing cassandra.yaml-style sizes with decimal units (MB/GB) into APIs expecting binary human-readable units; programmatic config generation emitting unspaced or unprefixed values; whitespace/case mistakes.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Commit log position must be given as <segment>,<position>
- Unexpected string: ${tokenScanner.next()}
- Invalid modifier specification: '${spec.substring(next, end)
- Invalid TokenRange:
- %s is not a valid function resource name. It must end with "
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/15a2fbefb196b9f4.
Report an issue: GitHub.