apache/hadoop · error · IOException

Invalid HTTP GET operation [{0}]

Error message

Invalid HTTP GET operation [{0}]

What it means

HttpFSServer.get() dispatches on the op parameter over the operations valid for HTTP GET and falls into the default branch, throwing IOException('Invalid HTTP GET operation [<op>]') for anything else. This is HttpFS's client-facing 'verb/operation mismatch' signal — the op name may be valid HDFS but not for GET, or not valid at all for this server version.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java:594

      response = Response.ok(js).type(MediaType.APPLICATION_JSON).build();
      break;
    }
    case GETSTATUS: {
      FSOperations.FSStatus command = new FSOperations.FSStatus(path);
      @SuppressWarnings("rawtypes") Map js = fsExecute(user, command);
      response = Response.ok(js).type(MediaType.APPLICATION_JSON).build();
      break;
    }
    case GETTRASHROOTS: {
      Boolean allUsers = params.get(AllUsersParam.NAME, AllUsersParam.class);
      FSOperations.FSGetTrashRoots command = new FSOperations.FSGetTrashRoots(allUsers);
      Map json = fsExecute(user, command);
      AUDIT_LOG.info("allUsers [{}]", allUsers);
      response = Response.ok(json).type(MediaType.APPLICATION_JSON).build();
      break;
    }
    default: {
      throw new IOException(
          MessageFormat.format("Invalid HTTP GET operation [{0}]", op.value()));
    }
    }
    return response;
  }

  /**
   * Create an open redirection URL from a request. It points to the same
   * HttpFS endpoint but removes the "redirect" parameter.
   * @param uriInfo uri info of the request.
   * @return URL for the redirected location.
   */
  private URI createOpenRedirectionURL(UriInfo uriInfo) {
    UriBuilder uriBuilder = uriInfo.getRequestUriBuilder();
    uriBuilder.replaceQueryParam(NoRedirectParam.NAME, (Object[])null);
    return uriBuilder.build((Object[])null);
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Check the WebHDFS/HttpFS REST spec for the operation and re-issue with the correct HTTP verb (MKDIRS/RENAME/SETPERMISSION... -> PUT; APPEND -> POST; DELETE -> DELETE; opens/lists -> GET).
  2. Verify the op spelling exactly (case-sensitive) against the operation enum of the server's Hadoop version.
  3. If the op simply does not exist on this server, upgrade HttpFS to the Hadoop version whose client you use.

Example fix

# before
$ curl 'http://host:14000/webhdfs/v1/tmp/dir?op=MKDIRS&user.name=alice&permissions=755'

# after
$ curl -X PUT 'http://host:14000/webhdfs/v1/tmp/dir?op=MKDIRS&user.name=alice&permissions=755'
Defensive patterns

Strategy: validation

Validate before calling

Set<String> GET_OPS = Set.of("OPEN","GETFILESTATUS","LISTSTATUS","GETCONTENTSUMMARY",
    "GETFILECHECKSUM","GETHOMEDIRECTORY","GETTRASHROOT","GETTRASHROOTS",
    "GETACLSTATUS","LISTXATTRS","GETXATTRS","CHECKACCESS","GETALLSTORAGEPOLICY",
    "GETSTORAGEPOLICY","GETSNAPSHOTLIST","GETSNAPSHOTTABLEDIRECTORYLIST",
    "GETFILEBLOCKLOCATIONS","GETECCODECS","GETErasureCodingPolicy".toUpperCase(),
    "INSTRUMENTATION","STATUS");
if (!GET_OPS.contains(op)) throw new IllegalArgumentException(op + " is not a GET operation");

Type guard

static boolean isValidGetOp(String op) {
  return Set.of("OPEN","LISTSTATUS","GETFILESTATUS","GETFILECHECKSUM",
    "GETCONTENTSUMMARY","GETHOMEDIRECTORY","GETTRASHROOT","GETTRASHROOTS",
    "GETACLSTATUS","GETXATTRS","LISTXATTRS","CHECKACCESS","GETSTORAGEPOLICY",
    "GETALLSTORAGEPOLICY","GETSNAPSHOTLIST","GETSNAPSHOTTABLEDIRECTORYLIST",
    "GETFILEBLOCKLOCATIONS","GETECCODECS","INSTRUMENTATION").contains(op);
}

Try / catch

try {
  resp = http.get(buildUrl(op));
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().contains("Invalid HTTP GET operation")) {
    throw new IllegalArgumentException("Wrong verb or typo for op " + op, e);
  }
  throw e;
}

Prevention

When it happens

Trigger: GET ?op=MKDIRS (MKDIRS is a PUT op); GET ?op=SETREPLICATION (a PUT op); a typo like op=GETFILESTATUSE; using an operation added in a newer Hadoop release against an older HttpFS server (e.g. GETECCODECS on an HttpFS from an earlier branch); hand-rolled clients defaulting every call to GET.

Common situations: Porting REST scripts between WebHDFS gateway implementations with slightly different op sets; version skew between hadoop-client and the HttpFS server after a rolling upgrade; curl examples copied with the wrong verb; tools like wget that only do GET.

Related errors


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