{"record":{"id":"906112f36e1f53e8","repo":"apache/druid","slug":"invalid-format-of-number-number-is-blank","errorCode":null,"errorMessage":"Invalid format of number: number is blank","messagePattern":"Invalid format of number: number is blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java","lineNumber":98,"sourceCode":"  public static HumanReadableBytes valueOf(int bytes)\n  {\n    return new HumanReadableBytes(bytes);\n  }\n\n  public static HumanReadableBytes valueOf(long bytes)\n  {\n    return new HumanReadableBytes(bytes);\n  }\n\n  public static long parse(String number)\n  {\n    if (number == null) {\n      throw new IAE(\"Invalid format of number: number is null\");\n    }\n\n    number = number.trim();\n    if (number.length() == 0) {\n      throw new IAE(\"Invalid format of number: number is blank\");\n    }\n\n    return parseInner(number);\n  }\n\n  /**\n   * parse the case-insensitive string number, which is either:\n   * <p>\n   * a number string\n   * <p>\n   * or\n   * <p>\n   * a number string with a suffix which indicates the unit the of number\n   * the unit must be one of following\n   * k - kilobyte = 1000\n   * m - megabyte = 1,000,000\n   * g - gigabyte = 1,000,000,000\n   * t - terabyte = 1,000,000,000,000","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java#L80-L116","documentation":"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.","triggerScenarios":"Calling HumanReadableBytes.parse(\"\") or parse(\"   \") — commonly from an environment variable or properties file where the key exists but its value is blank.","commonSituations":"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.","solutions":["Provide a valid byte-size string (e.g. '512MiB', '1024') instead of the blank value.","Check config sources: empty environment variables or unset property substitutions often yield ''.","Use HumanReadableBytes.parse with a default or guard the caller against blank input."],"exampleFix":"// before\nlong bytes = HumanReadableBytes.parse(System.getenv(\"BUFFER_SIZE\")); // set to \"\"\n// after\nString raw = System.getenv(\"BUFFER_SIZE\");\nlong bytes = (raw == null || raw.trim().isEmpty()) ? HumanReadableBytes.parse(\"1gb\") : HumanReadableBytes.parse(raw);","handlingStrategy":"validation","validationCode":"if (raw != null && raw.trim().isEmpty()) {\n  raw = \"1gb\"; // substitute default for blank\n}\nlong bytes = HumanReadableBytes.parse(raw);","typeGuard":"static boolean isNonBlank(String s) {\n  return s != null && !s.trim().isEmpty();\n}","tryCatchPattern":"try {\n  long bytes = HumanReadableBytes.parse(raw);\n} catch (IAE e) {\n  if (e.getMessage().contains(\"blank\")) { bytes = DEFAULT_BYTES; }\n  else throw e;\n}","preventionTips":["Check that env vars and properties keys have actual values, not just presence","Trim user/UI input before storing size configuration","Reject blank size fields at config-validation time with the property name","Provide explicit defaults in properties files rather than empty values"],"tags":["configuration","parsing","blank-value"],"backgroundTag":"empty-required-field","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}