apache/hadoop · error · IllegalArgumentException

Invalid Operation [{0}]

Error message

Invalid Operation [{0}]

What it means

The op value is resolved with Enum.valueOf on HttpFSFileSystem.Operation after upper-casing (ParametersProvider.java:76); a name that is not an enum constant throws IllegalArgumentException("Invalid Operation [str]") → HTTP 400. Names are case-insensitive on the wire ('getfilestatus' works), but non-existent verbs do not. Valid names are the WebHDFS operations (OPEN, CREATE, APPEND, RENAME, DELETE, LISTSTATUS, GETFILESTATUS, SETREPLICATION, GETXATTR, ...).

Source

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

  public Parameters get(HttpServletRequest request) {
    Map<String, List<Param<?>>> map = new HashMap<>();

    Map<String, String[]> queryString = request.getParameterMap();
    String str = null;
    if(queryString.containsKey(driverParam)) {
      str = queryString.get(driverParam)[0];
    }
    if (str == null) {
      throw new IllegalArgumentException(
        MessageFormat.format("Missing Operation parameter [{0}]",
                             driverParam));
    }
    Enum op;
    try {
      op = Enum.valueOf(enumClass, StringUtils.toUpperCase(str));
    } catch (IllegalArgumentException ex) {
      throw new IllegalArgumentException(
        MessageFormat.format("Invalid Operation [{0}]", str));
    }
    if (!paramsDef.containsKey(op)) {
      throw new IllegalArgumentException(
        MessageFormat.format("Unsupported Operation [{0}]", op));
    }
    for (Class<Param<?>> paramClass : paramsDef.get(op)) {
      Param<?> param = newParam(paramClass);
      List<Param<?>> paramList = Lists.newArrayList();
      String[] ps = queryString.get(param.getName());
      if (ps != null) {
        for (String p : ps) {
          try {
            param.parseParam(p);
          }
          catch (Exception ex) {
            throw new IllegalArgumentException(ex.toString(), ex);
          }

View on GitHub (pinned to 2add963021)

Solutions

  1. Use a valid WebHDFS operation name in op, exactly as documented for the server's version (e.g. op=OPEN, op=GETFILESTATUS).
  2. Resolve version skew: send newer operations only to servers that support them, or upgrade httpfs.
  3. Replace CLI-style verbs with their WebHDFS equivalents (rm → DELETE, ls → LISTSTATUS, read → OPEN).
  4. Catch the 400 client-side and surface the invalid value to the caller/log.

Example fix

# before
curl 'http://nn:14000/webhdfs/v1/file?op=read&user.name=hdfs'          # 400 Invalid Operation [read]

# after
curl 'http://nn:14000/webhdfs/v1/file?op=OPEN&user.name=hdfs'          # 200
Defensive patterns

Strategy: validation

Validate before calling

Set<String> OPS = Set.of("OPEN", "GETFILESTATUS", "LISTSTATUS", "CREATE", "DELETE", "RENAME", "SETREPLICATION");
String op = rawOp == null ? null : rawOp.toUpperCase(Locale.ROOT);
if (op == null || !OPS.contains(op)) throw new IllegalArgumentException("unsupported op: " + rawOp);

Type guard

static boolean isValidOp(String s, Set<String> knownOps) {
  return s != null && knownOps.contains(s.toUpperCase(Locale.ROOT));
}

Try / catch

try {
  Response r = target.queryParam("op", op).request().get(Response.class);
} // client side: on 400, parse the body for 'Invalid Operation' and surface rawOp
catch (ProcessingException ex) { /* connection issues, not validation */ throw ex; }

Prevention

When it happens

Trigger: Requests like ?op=read, ?op=list, ?op=rm, or typos like ?op=GETFILESTAT. Also version skew: a client using an operation constant added in a newer release (e.g. GETECCODECS) against an older httpfs whose enum lacks it.

Common situations: Porting vocabulary from the HDFS CLI or other object-store APIs (rm, ls, read, stat); typo'd operation names in scripts; clients built against a different Hadoop version than the server.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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