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 number

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Provide a non-null default before parsing (e.g. config value or a fallback like "1gb")
  2. Use the HumanReadableBytes constructor with a primitive long instead of parsing a possibly-null string
  3. Validate/trim configuration at load time and fail early with a clear message naming the missing key
  4. 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

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


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/7e48c1b78c6d956f. Report an issue: GitHub.