{"record":{"id":"a7b2402670a4841f","repo":"apache/hadoop","slug":"invalid-parameter-range-name-value-min-a7b240","errorCode":null,"errorMessage":"Invalid parameter range: {name} = {value} < {min}","messagePattern":"Invalid parameter range: (.+?) = (.+?) < (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/LongParam.java","lineNumber":33,"sourceCode":" * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage org.apache.hadoop.hdfs.web.resources;\n\n/** Long parameter. */\nabstract class LongParam extends Param<Long, LongParam.Domain> {\n  LongParam(final Domain domain, final Long value, final Long min,\n            final Long max) {\n    super(domain, value);\n    checkRange(min, max);\n  }\n\n  private void checkRange(final Long min, final Long max) {\n    if (value == null) {\n      return;\n    }\n    if (min != null && value < min) {\n      throw new IllegalArgumentException(\"Invalid parameter range: \" + getName()\n          + \" = \" + domain.toString(value) + \" < \" + domain.toString(min));\n    }\n    if (max != null && value > max) {\n      throw new IllegalArgumentException(\"Invalid parameter range: \" + getName()\n          + \" = \" + domain.toString(value) + \" > \" + domain.toString(max));\n    }\n  }\n\n  @Override\n  public String toString() {\n    return getName() + \"=\" + domain.toString(getValue());\n  }\n\n  /** @return the parameter value as a string */\n  @Override\n  public String getValueString() {\n    return domain.toString(getValue());\n  }","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/LongParam.java#L15-L51","documentation":"LongParam is the base class for WebHDFS 64-bit query parameters; checkRange (LongParam.java:24-40) throws this IllegalArgumentException when a non-null value is below the subclass minimum. Concrete floors in this codebase: offset >= 0 and length >= 0 (OPEN/APPEND reads and CREATE lengths), newlength >= 0 (TRUNCATE), blocksize >= 1 (CREATE), modificationtime/accesstime >= -1 (SETTIMES, where -1 means 'do not change'), and namespace/storagespace quota >= QUOTA_RESET (-1, SETQUOTA/SETQUOTABYSTORAGETYPE).","triggerScenarios":"?op=OPEN&offset=-1; ?op=CREATE&length=-100; ?op=TRUNCATE&newlength=-1; ?op=CREATE&blocksize=0; ?op=SETTIMES&modificationtime=-2; ?op=SETQUOTA&namespacequota=-2.","commonSituations":"Passing -1 as an 'unset/skip' sentinel to parameters whose floor is 0 (offset, length, newlength, blocksize); computing sizes as long that underflows; quota scripts that send -2 where -1 (reset quota) was intended.","solutions":["Raise the value to the parameter's floor: offset/length/newlength >= 0, blocksize >= 1, times >= -1, quotas >= -1.","To express 'not specified', omit the parameter (or send 'null') instead of a negative sentinel.","For SETTIMES use -1 only, never lower; for quota reset send -1 (QUOTA_RESET)."],"exampleFix":"# before\ncurl -i -X PUT \"http://nn:9870/webhdfs/v1/f?op=TRUNCATE&newlength=-1\"\n# after\ncurl -i -X PUT \"http://nn:9870/webhdfs/v1/f?op=TRUNCATE&newlength=0\"","handlingStrategy":"validation","validationCode":"static long checkedLong(String name, Long v, long min) {\n  if (v == null) return min == 0 ? 0L : -1L;   // use each param's documented default\n  if (v < min) throw new IllegalArgumentException(name + \" must be >= \" + min + \": \" + v);\n  return v;\n}","typeGuard":"static boolean isNonNegative(Long v) { return v == null || v >= 0L; }","tryCatchPattern":null,"preventionTips":["Map 'unspecified' to omitting the parameter, never to -1/0 sentinels for offset/length/newlength/blocksize.","Remember each parameter's floor: offset/length/newlength >= 0, blocksize >= 1, times and quotas >= -1.","Validate computed sizes for underflow before building the request."],"tags":["webhdfs","query-param","range-validation","long","hdfs"],"backgroundTag":"query-parameter-out-of-range","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}