{"record":{"id":"7e48c1b78c6d956f","repo":"apache/druid","slug":"invalid-format-of-number-number-is-null","errorCode":null,"errorMessage":"Invalid format of number: number is null","messagePattern":"Invalid format of number: number is null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java","lineNumber":93,"sourceCode":"  public String toString()\n  {\n    return String.valueOf(bytes);\n  }\n\n  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","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java#L75-L111","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlong bytes = HumanReadableBytes.parse(props.getProperty(\"druid.buffer.size\")); // null\n// after\nString raw = props.getProperty(\"druid.buffer.size\", \"1gb\");\nlong bytes = HumanReadableBytes.parse(raw);","handlingStrategy":"type-guard","validationCode":"if (raw == null) {\n  raw = \"1gb\"; // default\n}\nlong bytes = HumanReadableBytes.parse(raw);","typeGuard":"static Long parseSafe(String s, Long fallback) {\n  return (s == null || s.trim().isEmpty()) ? fallback : HumanReadableBytes.parse(s);\n}","tryCatchPattern":"try {\n  long bytes = HumanReadableBytes.parse(raw);\n} catch (IAE e) {\n  long bytes = DEFAULT_BYTES; // apply default and log\n}","preventionTips":["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+"],"tags":["configuration","parsing","null"],"backgroundTag":"null-argument","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"}