apache/hadoop · error · IllegalArgumentException

Parameter [{0}], invalid value [{1}], value must be [{2}]

Error message

Parameter [{0}], invalid value [{1}], value must be [{2}]

What it means

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.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/StringParam.java:49

  }

  public StringParam(String name, String defaultValue, Pattern pattern) {
    super(name, defaultValue);
    this.pattern = pattern;
    parseParam(defaultValue);
  }

  @Override
  public String parseParam(String str) {
    try {
      if (str != null) {
        str = str.trim();
        if (str.length() > 0) {
          value = parse(str);
        }
      }
    } catch (Exception ex) {
      throw new IllegalArgumentException(
        MessageFormat.format("Parameter [{0}], invalid value [{1}], value must be [{2}]",
                             getName(), str, getDomain()));
    }
    return value;
  }

  @Override
  protected String parse(String str) throws Exception {
    if (pattern != null) {
      if (!pattern.matcher(str).matches()) {
        throw new IllegalArgumentException("Invalid value");
      }
    }
    return str;
  }

  @Override
  protected String getDomain() {

View on GitHub (pinned to 2add963021)

Solutions

  1. Send the value in the form the printed regex demands, e.g. xattr.name=user.myattr.
  2. Copy the domain regex from the 400 body into client-side validation before sending the request.
  3. For custom StringParams, keep the pattern as loose as the semantics allow and validate the rest elsewhere.
  4. URL-encode values; avoid newlines and tabs that regexes typically reject.

Example fix

# before
curl 'http://nn:14000/webhdfs/v1/f?op=GETXATTR&xattr.name=myattr&user.name=hdfs'
# 400: Parameter [xattr.name], invalid value [myattr], value must be [user|trusted|security|system\..+]

# after
curl 'http://nn:14000/webhdfs/v1/f?op=GETXATTR&xattr.name=user.myattr&user.name=hdfs'
Defensive patterns

Strategy: validation

Validate before calling

Pattern XATTR = Pattern.compile("(user|trusted|security|system)\\..+");
String name = params.get("xattr.name");
if (name != null && !XATTR.matcher(name).matches()) {
  throw new IllegalArgumentException("xattr.name must be namespace.name (e.g. user.myattr), got " + name);
}

Type guard

static boolean matchesDomain(String v, Pattern p) {
  return v == null || p.matcher(v).matches();
}

Try / catch

try {
  param.parseParam(str);
} catch (IllegalArgumentException ex) {
  // 400: message carries the parameter name and the required regex
  return badRequest(ex.getMessage());
}

Prevention

When it happens

Trigger: 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.

Common situations: xattr names sent without the user. namespace; values copied from other tools with different naming rules; encoding issues introducing characters the regex rejects.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/d7d9e9dc4729e42b. Report an issue: GitHub.