apache/druid · error · IllegalArgumentException
Invalid format of number: number is null
Error message
Invalid format of number: number is null
What it means
HumanReadableBytes.parse throws this IllegalArgumentException when passed a null string. The parser requires a concrete textual size value such as "100mb"; null carries no parseable information, so it is rejected immediately.
Source
Thrown at processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java:93
public String toString()
{
return String.valueOf(bytes);
}
public static HumanReadableBytes valueOf(int bytes)
{
return new HumanReadableBytes(bytes);
}
public static HumanReadableBytes valueOf(long bytes)
{
return new HumanReadableBytes(bytes);
}
public static long parse(String number)
{
if (number == null) {
throw new IAE("Invalid format of number: number is null");
}
number = number.trim();
if (number.length() == 0) {
throw new IAE("Invalid format of number: number is blank");
}
return parseInner(number);
}
/**
* parse the case-insensitive string number, which is either:
* <p>
* a number string
* <p>
* or
* <p>
* a number string with a suffix which indicates the unit the of numberView on GitHub (pinned to 9b90983fd2)
Solutions
- Provide a non-null default before parsing (e.g. config value or a fallback like "1gb")
- Use the HumanReadableBytes constructor with a primitive long instead of parsing a possibly-null string
- Validate/trim configuration at load time and fail early with a clear message naming the missing key
- Catch IAE around parse() and substitute a sensible default
Example fix
// before
long bytes = HumanReadableBytes.parse(props.getProperty("druid.buffer.size")); // null
// after
String raw = props.getProperty("druid.buffer.size", "1gb");
long bytes = HumanReadableBytes.parse(raw); Defensive patterns
Strategy: type-guard
Validate before calling
if (raw == null) {
raw = "1gb"; // default
}
long bytes = HumanReadableBytes.parse(raw); Type guard
static Long parseSafe(String s, Long fallback) {
return (s == null || s.trim().isEmpty()) ? fallback : HumanReadableBytes.parse(s);
} Try / catch
try {
long bytes = HumanReadableBytes.parse(raw);
} catch (IAE e) {
long bytes = DEFAULT_BYTES; // apply default and log
} Prevention
- Never pass possibly-null config strings directly to parse; apply defaults first
- Validate configuration keys at load time and report missing keys by name
- Prefer HumanReadableBytes.valueOf(long) for programmatic values
- Use Objects.requireNonNullElse(raw, "1gb") style defaults in Java 9+
When it happens
Trigger: Calling HumanReadableBytes.parse(null), typically when a config string property is absent and the code passes the null straight through instead of applying a default.
Common situations: Missing configuration key resolved to null before parsing; deserializing a JSON config that omitted the field; programmatic construction where the caller forgot to substitute a default value.
Related errors
- Metric [%s] not whitelisted.
- Invalid format of number: number is blank
- Invalid format of number: %s. Negative value is not allowed.
- Invalid format of number: %s
- Invalid format of number [%s]. The unit should be one of Pi/
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/7e48c1b78c6d956f.
Report an issue: GitHub.