{"record":{"id":"5a58d3553fa1800d","repo":"apache/druid","slug":"number-overflow-s","errorCode":null,"errorMessage":"Number overflow: %s","messagePattern":"Number overflow: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java","lineNumber":210,"sourceCode":"        base = isBinaryByte ? 1024L * 1024 * 1024 * 1024 * 1024 : 1_000_000_000_000_000L;\n        break;\n\n      default:\n        if (!Character.isDigit(unit)) {\n          throw new IAE(\"Invalid format of number: %s\", rawNumber);\n        }\n\n        //lastDigitIndex here holds the index which is prior to current digit\n        //move backward so that it's at the right place\n        lastDigitIndex++;\n        break;\n    }\n\n    try {\n      long value = Long.parseLong(number.substring(0, lastDigitIndex + 1)) * base;\n      if (base > 1 && value < base) {\n        //for base == 1, overflow has been checked in parseLong\n        throw new IAE(\"Number overflow: %s\", rawNumber);\n      }\n      return value;\n    }\n    catch (NumberFormatException e) {\n      throw new IAE(\"Invalid format or out of range of long: %s\", rawNumber);\n    }\n  }\n\n  public enum UnitSystem\n  {\n    /**\n     * also known as IEC format\n     * eg: B, KiB, MiB, GiB ...\n     */\n    BINARY_BYTE,\n\n    /**\n     * also known as SI format","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java#L192-L228","documentation":"After multiplying the parsed numeric value by the unit base, the result no longer fits in a long (or wrapped around), so HumanReadableBytes throws this IAE. The check is: when base > 1, the product must be >= base; a product smaller than base means long overflow occurred during multiplication. Values that already exceed Long.MAX_VALUE at parseLong time are caught separately by the NumberFormatException branch.","triggerScenarios":"Parsing a value whose magnitude times the unit base exceeds Long.MAX_VALUE, e.g. '9223372036854775807t' or '100P' with a binary base near the top of the long range; also huge literal numbers like '99999999999999999999'.","commonSituations":"Misconfigured size properties where someone typed gigabytes expecting megabytes ('9999999999g'), or auto-generated configs scaling a value into overflow; binary vs decimal base selection amplifying an already large number.","solutions":["Reduce the number so value * base fits in a long (max raw value is Long.MAX_VALUE / base)","Use a smaller unit suffix: '9223372036854775807' bytes is fine, but scale down 't'/'p' values","Verify you did not mean a decimal unit where binary was used or vice versa (e.g. '10P' vs '10PiB')"],"exampleFix":"// before\nHumanReadableBytes.parse(\"9999999999999t\"); // overflow\n// after\nHumanReadableBytes.parse(\"8388608t\"); // < Long.MAX_VALUE","handlingStrategy":"validation","validationCode":"static boolean fitsInLong(String s) {\n  try {\n    HumanReadableBytes h = HumanReadableBytes.parse(s);\n    return h.getBytes() >= 0;\n  } catch (IllegalArgumentException e) { return false; }\n}","typeGuard":"if (value > Long.MAX_VALUE / baseFor(unit)) { throw new IllegalArgumentException(\"too large: \" + s); }","tryCatchPattern":"try {\n  long bytes = HumanReadableBytes.valueOf(raw).getBytes();\n} catch (IllegalArgumentException e) {\n  log.warn(\"Size [%s] overflows long, clamping\", raw);\n  bytes = Long.MAX_VALUE;\n}","preventionTips":["Keep configured sizes well below Long.MAX_VALUE / unit base","Double-check unit suffix magnitude (t and p multiply by 10^12/10^15 or 2^40/2^50)","Prefer explicit byte counts for very large values"],"tags":["overflow","bytes","parsing"],"backgroundTag":"value-out-of-range","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}