{"record":{"id":"76016c00183a94a4","repo":"apache/hadoop","slug":"parameter-0-1-must-be-greater-than-or-eq","errorCode":null,"errorMessage":"parameter [{0}] = [{1}] must be greater than or equals zero","messagePattern":"parameter \\[(.+?)\\] = \\[(.+?)\\] must be greater than or equals zero","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/util/Check.java","lineNumber":196,"sourceCode":"   * @throws IllegalArgumentException if the integer is greater or equal to zero.\n   */\n  public static int ge0(int value, String name) {\n    return (int) ge0((long) value, name);\n  }\n\n  /**\n   * Verifies an long is greater or equal to zero.\n   *\n   * @param value integer value.\n   * @param name the name to use in the exception message.\n   *\n   * @return the value.\n   *\n   * @throws IllegalArgumentException if the long is greater or equal to zero.\n   */\n  public static long ge0(long value, String name) {\n    if (value < 0) {\n      throw new IllegalArgumentException(MessageFormat.format(\n        \"parameter [{0}] = [{1}] must be greater than or equals zero\", name, value));\n    }\n    return value;\n  }\n\n}\n","sourceCodeStart":178,"sourceCodeEnd":203,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/util/Check.java#L178-L203","documentation":"Check.ge0(long value, String name) (Check.java:194) throws this IllegalArgumentException when value < 0: the number must be non-negative (zero is allowed). Like gt0, it is an httpfs lib precondition helper; the int overload delegates to the long one.","triggerScenarios":"Check.ge0(-1, \"offset\") or any negative long/int, commonly because a 'not set' sentinel of -1 (e.g. an offset or default mtime of -1) reaches a field where negative values are meaningless.","commonSituations":"-1 'unset' sentinels flowing into fields that accept zero; subtraction underflow producing a negative count; user-supplied negative numbers not validated at the boundary.","solutions":["Use 0 instead of -1 as the default/unset value for fields validated with ge0.","Clamp or reject negative user input at the API boundary before it reaches the check.","If -1 is a meaningful sentinel in your code, skip the ge0 call for the unset case.","Add unit tests for 0 (valid) and -1 (throws) to lock the semantics."],"exampleFix":"// before\nlong newLength = conf.getLong(\"truncate.length\", -1L);\nCheck.ge0(newLength, \"truncate.length\"); // throws: must be >= zero\n\n// after\nlong newLength = conf.getLong(\"truncate.length\", 0L);\nCheck.ge0(newLength, \"truncate.length\"); // ok","handlingStrategy":"validation","validationCode":"long offset = opts.get(\"offset\", -1L);\nif (offset < 0) {\n  throw new IllegalArgumentException(\"offset must be >= 0, got \" + offset);\n}","typeGuard":"static boolean isNonNegative(long v) { return v >= 0; }","tryCatchPattern":"try {\n  Check.ge0(value, name);\n} catch (IllegalArgumentException ex) {\n  throw new ConfigurationException(\"Invalid config value: \" + ex.getMessage(), ex);\n}","preventionTips":["Use 0, not -1, as the default for fields validated with ge0.","Reject negative user input at the API boundary before it reaches library calls.","Lock semantics with tests: 0 valid, -1 throws."],"tags":["java","hadoop","httpfs","validation","numeric"],"backgroundTag":"value-must-be-non-negative","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}