apache/hadoop · error · IllegalArgumentException

Invalid value

Error message

Invalid value

What it means

StringParam.parse (StringParam.java:60) throws this bare IllegalArgumentException("Invalid value") when the configured pattern does not match the string. It is an internal sentinel: the public entry point StringParam.parseParam catches every exception and rethrows the parameterized message (error 3690), so end users should never see this raw text — it appears only when parse() is invoked directly, e.g. by unit tests or subclasses reusing parse() internally.

Source

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

      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() {
    return (pattern == null) ? "a string" : pattern.pattern();
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. Call parseParam(str), never parse(str), from application code — you get the wrapped message naming the parameter and the required regex.
  2. Fix the value to satisfy the subclass pattern.
  3. When subclassing StringParam, set a descriptive pattern since getDomain() surfaces it in client-visible errors.

Example fix

// before
new XattrNameParam().parse("myattr"); // throws bare 'Invalid value'

// after
new XattrNameParam().parseParam("myattr"); // 'Parameter [xattr.name], invalid value [myattr], value must be [..regex..]'
Defensive patterns

Strategy: validation

Validate before calling

String name = params.get("xattr.name");
if (name != null && !Pattern.matches("(user|trusted|security|system)\\..+", name)) {
  // do not send: value would fail the server-side pattern
  return badRequest("xattr.name must be namespace.name");
}

Type guard

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

Try / catch

// Do not call the protected parse() directly; parseParam wraps this sentinel
// into a message naming the parameter and the required regex:
try { param.parseParam(str); } catch (IllegalArgumentException ex) { return badRequest(ex.getMessage()); }

Prevention

When it happens

Trigger: Direct invocation of a StringParam subclass's parse("bad-value") — bypassing parseParam — in tests or custom code; any value that violates the subclass Pattern (e.g. an xattr name without namespace prefix) reaches this throw on the normal path but is immediately wrapped.

Common situations: Test code exercising parse() directly; custom frameworks calling the protected parse() for internal reuse and leaking the uninformative message into logs.

Related errors


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