{"record":{"id":"0c456f511ed5ec21","repo":"apache/hadoop","slug":"str-is-not-a-valid-get-operation","errorCode":null,"errorMessage":"{str} is not a valid GET operation.","messagePattern":"(.+?) is not a valid GET operation\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/GetOpParam.java","lineNumber":135,"sourceCode":"      return NAME + \"=\" + this;\n    }\n  }\n\n  private static final Domain<Op> DOMAIN = new Domain<>(NAME, Op.class);\n\n  /**\n   * Constructor.\n   * @param str a string representation of the parameter value.\n   */\n  public GetOpParam(final String str) {\n    super(DOMAIN, getOp(str));\n  }\n\n  private static Op getOp(String str) {\n    try {\n      return DOMAIN.parse(str);\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(str + \" is not a valid \" + Type.GET\n          + \" operation.\");\n    }\n  }\n\n  @Override\n  public String getName() {\n    return NAME;\n  }\n}\n","sourceCodeStart":117,"sourceCodeEnd":145,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/GetOpParam.java#L117-L145","documentation":"GetOpParam parses the 'op' query parameter of WebHDFS/HttpFS GET requests against the Op enum in GetOpParam.java:25-73 (OPEN, GETFILESTATUS, LISTSTATUS, GETCONTENTSUMMARY, GETQUOTAUSAGE, GETFILECHECKSUM, GETHOMEDIRECTORY, GETDELEGATIONTOKEN, GET_BLOCK_LOCATIONS, GETFILEBLOCKLOCATIONS, GETACLSTATUS, GETXATTRS, GETTRASHROOT, LISTXATTRS, GETALLSTORAGEPOLICY, GETSTORAGEPOLICY, GETECPOLICY, CHECKACCESS, LISTSTATUS_BATCH, GETSERVERDEFAULTS, GETSNAPSHOTDIFF, GETSNAPSHOTDIFFLISTING, GETSNAPSHOTTABLEDIRECTORYLIST, GETLINKTARGET, GETFILELINKSTATUS, GETSTATUS, GETECPOLICIES, GETECCODECS, GETTRASHROOTS, GETSNAPSHOTLIST, NULL). Matching is case-insensitive (Enum.valueOf after toUpperCase); anything else throws this IllegalArgumentException, surfaced as HTTP 400.","triggerScenarios":"GET ?op=getfilestat (missing 'us'), ?op=LIST (instead of LISTSTATUS), ?op=GETFILELOCATION (private op, not in this enum), or using a PUT/POST op with GET, e.g. ?op=SETPERMISSION or ?op=APPEND on a GET request.","commonSituations":"Version drift: ops added in newer Hadoop releases (GETQUOTAUSAGE, GETSNAPSHOTDIFFLISTING, GETECCODECS, GETSERVERDEFAULTS) fail with this exact error against older NameNodes; mixing op names between WebHDFS and HttpFS docs; shell scripts with case-agnostic typos that survive review because the value looks plausible.","solutions":["Correct the op value to one of the GET Op enum constants listed in GetOpParam.java:25-73 (e.g. GETFILESTATUS, LISTSTATUS, OPEN).","Verify the HTTP method: GET-only ops fail here if sent as PUT/POST and vice versa.","If the op looks valid, check NameNode version support — newer ops (GETQUOTAUSAGE, GETSNAPSHOTDIFFLISTING) need Hadoop 3.x; use the older equivalent (GETCONTENTSUMMARY) on 2.x.","Prefer the webhdfs:// Java FileSystem client, which only emits supported op values."],"exampleFix":"# before\ncurl -i \"http://nn:9870/webhdfs/v1/tmp/f?op=GETFILESTAT\"\n# after\ncurl -i \"http://nn:9870/webhdfs/v1/tmp/f?op=GETFILESTATUS\"","handlingStrategy":"validation","validationCode":"private static final Set<String> GET_OPS = Set.of(\"OPEN\",\"GETFILESTATUS\",\"LISTSTATUS\",\"GETCONTENTSUMMARY\",\"GETQUOTAUSAGE\",\"GETFILECHECKSUM\",\"GETHOMEDIRECTORY\",\"GETDELEGATIONTOKEN\",\"GETFILEBLOCKLOCATIONS\",\"GETACLSTATUS\",\"GETXATTRS\",\"LISTXATTRS\",\"GETTRASHROOT\",\"GETALLSTORAGEPOLICY\",\"GETSTORAGEPOLICY\",\"GETECPOLICY\",\"CHECKACCESS\",\"LISTSTATUS_BATCH\",\"GETSERVERDEFAULTS\",\"GETSNAPSHOTDIFF\",\"GETSNAPSHOTDIFFLISTING\",\"GETSNAPSHOTTABLEDIRECTORYLIST\",\"GETLINKTARGET\",\"GETFILELINKSTATUS\",\"GETSTATUS\",\"GETECPOLICIES\",\"GETTRASHROOTS\",\"GETSNAPSHOTLIST\");\nstatic String checkedGetOp(String op) {\n  String v = op.toUpperCase(Locale.ROOT);\n  if (!GET_OPS.contains(v)) throw new IllegalArgumentException(\"unsupported GET op for this cluster: \" + op);\n  return v;\n}","typeGuard":"static boolean isSupportedGetOp(String op, Set<String> supported) {\n  return op != null && supported.contains(op.toUpperCase(Locale.ROOT));\n}","tryCatchPattern":"try { ... } catch (IOException e) {\n  RemoteException re = (RemoteException) (e instanceof RemoteException ? e : null);\n  if (re != null && re.getClassName().endsWith(\"IllegalArgumentException\") && re.getMessage().contains(\"valid GET operation\")) {\n    // typo or version drift: cross-check op against the cluster's hadoop version\n  }\n}","preventionTips":["Pin the op vocabulary per target Hadoop version (ops like GETQUOTAUSAGE do not exist on 2.x).","Wrap REST calls behind a client class that owns the enum of allowed ops.","Integration-test each op once against a mini-cluster in CI to catch version drift at build time."],"tags":["webhdfs","http-get","query-param","hdfs","rest-api"],"backgroundTag":"webhdfs-invalid-op-parameter","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}