apache/hadoop · error · IllegalArgumentException
Invalid value for webhdfs parameter "op"
Error message
Invalid value for webhdfs parameter "op"
What it means
The op parameter value is not one of the six read-only operations FSImageHandler implements (GETFILESTATUS, LISTSTATUS, GETACLSTATUS, GETXATTRS, LISTXATTRS, GETCONTENTSUMMARY); the default branch of the switch throws this IllegalArgumentException, which becomes HTTP 400. The fsimage is a static snapshot, so any op needing live NameNode state or write access is inherently unsupported here.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FSImageHandler.java:119
case "LISTSTATUS":
content = image.listStatus(path);
break;
case "GETACLSTATUS":
content = image.getAclStatus(path);
break;
case "GETXATTRS":
List<String> names = getXattrNames(decoder);
String encoder = getEncoder(decoder);
content = image.getXAttrs(path, names, encoder);
break;
case "LISTXATTRS":
content = image.listXAttrs(path);
break;
case "GETCONTENTSUMMARY":
content = image.getContentSummary(path);
break;
default:
throw new IllegalArgumentException("Invalid value for webhdfs parameter"
+ " \"op\"");
}
LOG.info("op=" + op + " target=" + path);
DefaultFullHttpResponse resp = new DefaultFullHttpResponse(HTTP_1_1,
HttpResponseStatus.OK, Unpooled.wrappedBuffer(content
.getBytes(StandardCharsets.UTF_8)));
resp.headers().set(CONTENT_TYPE, APPLICATION_JSON_UTF8);
resp.headers().set(CONTENT_LENGTH, resp.content().readableBytes());
resp.headers().set(CONNECTION, CLOSE);
ctx.write(resp).addListener(ChannelFutureListener.CLOSE);
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
ctx.flush();
}View on GitHub (pinned to 2add963021)
Solutions
- Switch to one of the supported read-only ops: GETFILESTATUS, LISTSTATUS, GETACLSTATUS, GETXATTRS, LISTXATTRS, GETCONTENTSUMMARY.
- For file contents or writes, target the live cluster's WebHDFS, not the fsimage viewer.
- If a newer oiv build supports more read-only ops, upgrade the tooling Hadoop version.
Example fix
# before curl 'http://localhost:5978/webhdfs/v1/user/foo?op=OPEN' # -> 400 Invalid value for webhdfs parameter "op" # after curl 'http://localhost:5978/webhdfs/v1/user/foo?op=GETFILESTATUS'
Defensive patterns
Strategy: validation
Validate before calling
private static final Set<String> SUPPORTED_OPS = new HashSet<>(Arrays.asList(
"GETFILESTATUS", "LISTSTATUS", "GETACLSTATUS",
"GETXATTRS", "LISTXATTRS", "GETCONTENTSUMMARY"));
String op = params.get("op");
if (op == null || !SUPPORTED_OPS.contains(op.toUpperCase(Locale.ROOT))) {
throw new IllegalArgumentException("Unsupported op " + op + "; supported: " + SUPPORTED_OPS);
} Type guard
static boolean isSupportedOp(String op) {
return op != null && Arrays.asList("GETFILESTATUS", "LISTSTATUS",
"GETACLSTATUS", "GETXATTRS", "LISTXATTRS", "GETCONTENTSUMMARY")
.contains(op.toUpperCase(Locale.ROOT));
} Try / catch
// server side already maps this to HTTP 400 with a JSON RemoteException
// client side: branch on op before calling the read-only viewer
if (!isSupportedOp(requestedOp)) { useLiveWebHdfsInstead(requestedOp); } Prevention
- Remember the fsimage viewer is read-only metadata-only: no OPEN, no writes.
- Maintain a supported-ops allowlist in client code instead of assuming WebHDFS parity.
- Re-check the switch in FSImageHandler when upgrading Hadoop — the op set changes across versions.
When it happens
Trigger: Calling with op=OPEN (file contents are not stored in the image), write ops like op=MKDIRS/op=DELETE/op=SETPERMISSION, or a mis-typed value like op=GETFILESTATUS2 (values are upper-cased before the switch, so letter case itself is not the issue).
Common situations: Pointing an existing WebHDFS application or script at the offline viewer assuming full API parity; ops introduced in newer WebHDFS versions; configs reused between the live cluster and the viewer.
Related errors
- Param op must be specified.
- Path: {path} should start with /webhdfs/v1
- Storage policy name is empty.
- {} is not supported
- {} is not supported
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/e73171b68e6a2266.
Report an issue: GitHub.