{"record":{"id":"d7d9e9dc4729e42b","repo":"apache/hadoop","slug":"parameter-0-invalid-value-1-value-must-b-d7d9e9","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/StringParam.java","lineNumber":49,"sourceCode":"  }\n\n  public StringParam(String name, String defaultValue, Pattern pattern) {\n    super(name, defaultValue);\n    this.pattern = pattern;\n    parseParam(defaultValue);\n  }\n\n  @Override\n  public String parseParam(String str) {\n    try {\n      if (str != null) {\n        str = str.trim();\n        if (str.length() > 0) {\n          value = parse(str);\n        }\n      }\n    } catch (Exception ex) {\n      throw new IllegalArgumentException(\n        MessageFormat.format(\"Parameter [{0}], invalid value [{1}], value must be [{2}]\",\n                             getName(), str, getDomain()));\n    }\n    return value;\n  }\n\n  @Override\n  protected String parse(String str) throws Exception {\n    if (pattern != null) {\n      if (!pattern.matcher(str).matches()) {\n        throw new IllegalArgumentException(\"Invalid value\");\n      }\n    }\n    return str;\n  }\n\n  @Override\n  protected String getDomain() {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/StringParam.java#L31-L67","documentation":"StringParam overrides parseParam (StringParam.java:49) with the same contract as Param but re-implemented for strings: the value is trimmed and, if non-empty, handed to parse(), which enforces the subclass's optional Pattern; any failure throws IllegalArgumentException(\"Parameter [name], invalid value [str], value must be [pattern]\") where the domain is the regex itself (or 'a string' when no pattern). httpfs uses pattern-bound StringParams such as XattrNameParam.","triggerScenarios":"A WebHDFS xattr request with a name missing its namespace prefix, e.g. ?op=GETXATTR&xattr.name=myattr — the value must match XATTR_NAME_REGX (user./trusted./security./system. prefixed names). Also any custom StringParam subclass whose compiled Pattern rejects the sent value; a whitespace-only value is safe (kept as default) but a non-matching non-empty value throws.","commonSituations":"xattr names sent without the user. namespace; values copied from other tools with different naming rules; encoding issues introducing characters the regex rejects.","solutions":["Send the value in the form the printed regex demands, e.g. xattr.name=user.myattr.","Copy the domain regex from the 400 body into client-side validation before sending the request.","For custom StringParams, keep the pattern as loose as the semantics allow and validate the rest elsewhere.","URL-encode values; avoid newlines and tabs that regexes typically reject."],"exampleFix":"# before\ncurl 'http://nn:14000/webhdfs/v1/f?op=GETXATTR&xattr.name=myattr&user.name=hdfs'\n# 400: Parameter [xattr.name], invalid value [myattr], value must be [user|trusted|security|system\\..+]\n\n# after\ncurl 'http://nn:14000/webhdfs/v1/f?op=GETXATTR&xattr.name=user.myattr&user.name=hdfs'","handlingStrategy":"validation","validationCode":"Pattern XATTR = Pattern.compile(\"(user|trusted|security|system)\\\\..+\");\nString name = params.get(\"xattr.name\");\nif (name != null && !XATTR.matcher(name).matches()) {\n  throw new IllegalArgumentException(\"xattr.name must be namespace.name (e.g. user.myattr), got \" + name);\n}","typeGuard":"static boolean matchesDomain(String v, Pattern p) {\n  return v == null || p.matcher(v).matches();\n}","tryCatchPattern":"try {\n  param.parseParam(str);\n} catch (IllegalArgumentException ex) {\n  // 400: message carries the parameter name and the required regex\n  return badRequest(ex.getMessage());\n}","preventionTips":["Copy the domain regex from the error message into client-side validation.","URL-encode xattr names containing special characters.","Keep a parameter-to-domain table in client documentation."],"tags":["java","hadoop","httpfs","rest","webhdfs","regex","query-string"],"backgroundTag":"query-parameter-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}