{"record":{"id":"12d555f416a42d7b","repo":"apache/hadoop","slug":"parameter-0-invalid-value-1-value-must-b","errorCode":null,"errorMessage":"Parameter [{0}], invalid value [{1}], value must be [{2}]","messagePattern":"Parameter \\[(.+?)\\], invalid value \\[(.+?)\\], value must be \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/Param.java","lineNumber":43,"sourceCode":"@InterfaceAudience.Private\npublic abstract class Param<T> {\n  private String name;\n  protected T value;\n\n  public Param(String name, T defaultValue) {\n    this.name = name;\n    this.value = defaultValue;\n  }\n\n  public String getName() {\n    return name;\n  }\n\n  public T parseParam(String str) {\n    try {\n      value = (str != null && str.trim().length() > 0) ? parse(str) : value;\n    } catch (Exception ex) {\n      throw new IllegalArgumentException(\n        MessageFormat.format(\"Parameter [{0}], invalid value [{1}], value must be [{2}]\",\n                             name, str, getDomain()));\n    }\n    return value;\n  }\n\n  public T value() {\n    return value;\n  }\n\n  protected abstract String getDomain();\n\n  protected abstract T parse(String str) throws Exception;\n\n  @Override\n  public String toString() {\n    return (value != null) ? value.toString() : \"NULL\";\n  }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/Param.java#L25-L61","documentation":"Param.parseParam(String) (Param.java:43) is the generic query-parameter entry point of the httpfs wsrs framework: it trims the input, delegates to the subclass's protected parse(), and on ANY exception rethrows IllegalArgumentException(\"Parameter [name], invalid value [str], value must be [domain]\"), where the domain comes from getDomain() ('a long', 'a short', 'a boolean', or a regex). This is how malformed WebHDFS query values become HTTP 400 responses, and it wraps the specific parse failures such as errors 3684 and 3691.","triggerScenarios":"Any httpfs/WebHDFS REST call with a valid op but a malformed typed parameter: replication=abc (LongParam), permission=99999 (ShortParam overflow), modifiedtime=xyz, recursive=1 (BooleanParam). Each surfaces as a 400 whose body names the parameter, the bad value, and the required domain.","commonSituations":"Clients serializing numbers with units or separators ('10s', '1,000'); strings sent where numbers are expected; typo'd values; custom embedders forgetting to override getDomain(), leaving a vague hint in the 400 body.","solutions":["Send the value in the form the error's 'value must be' clause states: a long, a short, a boolean, or matching the printed regex.","Fix client serialization: no units, no thousands separators, no trailing whitespace or newlines.","For custom Param subclasses, implement getDomain() precisely so the 400 is self-documenting.","URL-encode parameter values correctly and avoid stray whitespace in generated URLs."],"exampleFix":"# before\n?op=SETREPLICATION&replication=double\n# 400: Parameter [replication], invalid value [double], value must be [a long]\n\n# after\n?op=SETREPLICATION&replication=2","handlingStrategy":"try-catch","validationCode":"String raw = params.get(\"replication\");\nif (raw != null) {\n  try { Long.parseLong(raw.trim()); }\n  catch (NumberFormatException e) { throw new IllegalArgumentException(\"replication must be a long: \" + raw); }\n}","typeGuard":null,"tryCatchPattern":"try {\n  param.parseParam(str);\n} catch (IllegalArgumentException ex) {\n  // the message names the parameter, the bad value, and the required domain\n  throw new BadRequestException(ex.getMessage(), ex);\n}","preventionTips":["Read the 'value must be' clause in the 400 body — it is the authoritative domain for that parameter.","Keep client serializers strict: no units, no separators, no trailing whitespace.","For custom Param subclasses, always override getDomain() with a precise description."],"tags":["java","hadoop","httpfs","rest","webhdfs","query-string","validation"],"backgroundTag":"query-parameter-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}