apache/druid · error · IllegalArgumentException

Invalid format of number: number is blank

Error message

Invalid format of number: number is blank

What it means

HumanReadableBytes.parse is a size-string validation helper: after the null check, it trims the string and rejects an empty/whitespace-only input with this IAE. A byte-size config value like '100MiB' was expected, but a blank string was supplied, typically from an empty property or environment substitution.

Source

Thrown at processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java:98

  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
   * the unit must be one of following
   * k - kilobyte = 1000
   * m - megabyte = 1,000,000
   * g - gigabyte = 1,000,000,000
   * t - terabyte = 1,000,000,000,000

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Provide a valid byte-size string (e.g. '512MiB', '1024') instead of the blank value.
  2. Check config sources: empty environment variables or unset property substitutions often yield ''.
  3. Use HumanReadableBytes.parse with a default or guard the caller against blank input.

Example fix

// before
long bytes = HumanReadableBytes.parse(System.getenv("BUFFER_SIZE")); // set to ""
// after
String raw = System.getenv("BUFFER_SIZE");
long bytes = (raw == null || raw.trim().isEmpty()) ? HumanReadableBytes.parse("1gb") : HumanReadableBytes.parse(raw);
Defensive patterns

Strategy: validation

Validate before calling

if (raw != null && raw.trim().isEmpty()) {
  raw = "1gb"; // substitute default for blank
}
long bytes = HumanReadableBytes.parse(raw);

Type guard

static boolean isNonBlank(String s) {
  return s != null && !s.trim().isEmpty();
}

Try / catch

try {
  long bytes = HumanReadableBytes.parse(raw);
} catch (IAE e) {
  if (e.getMessage().contains("blank")) { bytes = DEFAULT_BYTES; }
  else throw e;
}

Prevention

When it happens

Trigger: Calling HumanReadableBytes.parse("") or parse(" ") — commonly from an environment variable or properties file where the key exists but its value is blank.

Common situations: Empty value in runtime.properties or an unset-but-present env var; a UI submitting an empty size field; trimming logic leaving an empty string before parsing.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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