{"record":{"id":"71a60f36b290e906","repo":"apache/hadoop","slug":"invalid-parameter-range-name-value-min","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/IntegerParam.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/** Integer parameter. */\nabstract class IntegerParam extends Param<Integer, IntegerParam.Domain> {\n  IntegerParam(final Domain domain, final Integer value,\n      final Integer min, final Integer max) {\n    super(domain, value);\n    checkRange(min, max);\n  }\n\n  private void checkRange(final Integer min, final Integer 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/IntegerParam.java#L15-L51","documentation":"IntegerParam is the base class for WebHDFS integer query parameters; its constructor runs checkRange() (IntegerParam.java:24-40) and throws this IllegalArgumentException when a non-null value is below the subclass-declared minimum. In this codebase the concrete subclasses are BufferSizeParam (min 1, 'buffersize' on OPEN/CREATE/APPEND) and SnapshotDiffIndexParam (min -1, 'snapshotdiffindex' on GETSNAPSHOTDIFFLISTING), so the error means one of those parameters was sent too small. The server converts it to HTTP 400.","triggerScenarios":"OPEN/CREATE with ?buffersize=0 or a negative buffersize; GETSNAPSHOTDIFFLISTING with ?snapshotdiffindex=-2 (the -1 sentinel meaning 'from the beginning' is the floor).","commonSituations":"Passing io.file.buffer.size=0 from config straight into a WebHDFS URL; tools that let users type a buffer size without clamping; arithmetic that computes a size and underflows to 0 or negative before the request.","solutions":["Send buffersize >= 1 (e.g. the common 4096) or omit the parameter entirely — the server falls back to io.file.buffer.size from its config.","For snapshotdiffindex, use -1 or omit it to start from the beginning of the diff.","Clamp user-supplied sizes at your call site before building the URL."],"exampleFix":"# before\ncurl -i \"http://nn:9870/webhdfs/v1/f?op=OPEN&buffersize=0\"\n# after\ncurl -i \"http://nn:9870/webhdfs/v1/f?op=OPEN&buffersize=4096\"","handlingStrategy":"validation","validationCode":"static int checkedBufferSize(Integer v) {\n  if (v == null) return 4096;                 // omit param, server default applies\n  if (v < 1) throw new IllegalArgumentException(\"buffersize must be >= 1: \" + v);\n  return v;\n}","typeGuard":"static boolean isInRange(Integer v, int min) { return v == null || v >= min; }","tryCatchPattern":null,"preventionTips":["Clamp user-supplied numeric settings before building URLs.","Treat 0/negative as 'unset' at your config layer and omit the parameter instead of sending it.","Unit-test the URL builder with boundary values 0, -1, 1."],"tags":["webhdfs","query-param","range-validation","integer","hdfs"],"backgroundTag":"query-parameter-out-of-range","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}