{"record":{"id":"e73171b68e6a2266","repo":"apache/hadoop","slug":"invalid-value-for-webhdfs-parameter-op","errorCode":null,"errorMessage":"Invalid value for webhdfs parameter \"op\"","messagePattern":"Invalid value for webhdfs parameter \"op\"","errorType":"http","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FSImageHandler.java","lineNumber":119,"sourceCode":"    case \"LISTSTATUS\":\n      content = image.listStatus(path);\n      break;\n    case \"GETACLSTATUS\":\n      content = image.getAclStatus(path);\n      break;\n    case \"GETXATTRS\":\n      List<String> names = getXattrNames(decoder);\n      String encoder = getEncoder(decoder);\n      content = image.getXAttrs(path, names, encoder);\n      break;\n    case \"LISTXATTRS\":\n      content = image.listXAttrs(path);\n      break;\n    case \"GETCONTENTSUMMARY\":\n      content = image.getContentSummary(path);\n      break;\n    default:\n      throw new IllegalArgumentException(\"Invalid value for webhdfs parameter\"\n          + \" \\\"op\\\"\");\n    }\n\n    LOG.info(\"op=\" + op + \" target=\" + path);\n\n    DefaultFullHttpResponse resp = new DefaultFullHttpResponse(HTTP_1_1,\n        HttpResponseStatus.OK, Unpooled.wrappedBuffer(content\n            .getBytes(StandardCharsets.UTF_8)));\n    resp.headers().set(CONTENT_TYPE, APPLICATION_JSON_UTF8);\n    resp.headers().set(CONTENT_LENGTH, resp.content().readableBytes());\n    resp.headers().set(CONNECTION, CLOSE);\n    ctx.write(resp).addListener(ChannelFutureListener.CLOSE);\n  }\n\n  @Override\n  public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {\n    ctx.flush();\n  }","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FSImageHandler.java#L101-L137","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\ncurl 'http://localhost:5978/webhdfs/v1/user/foo?op=OPEN'\n# -> 400 Invalid value for webhdfs parameter \"op\"\n\n# after\ncurl 'http://localhost:5978/webhdfs/v1/user/foo?op=GETFILESTATUS'","handlingStrategy":"validation","validationCode":"private static final Set<String> SUPPORTED_OPS = new HashSet<>(Arrays.asList(\n    \"GETFILESTATUS\", \"LISTSTATUS\", \"GETACLSTATUS\",\n    \"GETXATTRS\", \"LISTXATTRS\", \"GETCONTENTSUMMARY\"));\n\nString op = params.get(\"op\");\nif (op == null || !SUPPORTED_OPS.contains(op.toUpperCase(Locale.ROOT))) {\n  throw new IllegalArgumentException(\"Unsupported op \" + op + \"; supported: \" + SUPPORTED_OPS);\n}","typeGuard":"static boolean isSupportedOp(String op) {\n  return op != null && Arrays.asList(\"GETFILESTATUS\", \"LISTSTATUS\",\n      \"GETACLSTATUS\", \"GETXATTRS\", \"LISTXATTRS\", \"GETCONTENTSUMMARY\")\n      .contains(op.toUpperCase(Locale.ROOT));\n}","tryCatchPattern":"// server side already maps this to HTTP 400 with a JSON RemoteException\n// client side: branch on op before calling the read-only viewer\nif (!isSupportedOp(requestedOp)) { useLiveWebHdfsInstead(requestedOp); }","preventionTips":["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."],"tags":["hdfs","offline-image-viewer","webhdfs","http","query-parameter","unsupported-operation"],"backgroundTag":"invalid-query-parameter","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}