{"record":{"id":"010c708641a2fc3c","repo":"apache/hadoop","slug":"str-is-not-a-valid-post-operation","errorCode":null,"errorMessage":"{str} is not a valid POST operation.","messagePattern":"(.+?) is not a valid POST 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/PostOpParam.java","lineNumber":92,"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 PostOpParam(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.POST\n          + \" operation.\");\n    }\n  }\n\n  @Override\n  public String getName() {\n    return NAME;\n  }\n}\n","sourceCodeStart":74,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/PostOpParam.java#L74-L102","documentation":"PostOpParam parses the 'op' query parameter of WebHDFS/HttpFS POST requests against the Op enum in PostOpParam.java:25-36: APPEND, CONCAT, TRUNCATE, UNSETECPOLICY, UNSETSTORAGEPOLICY, NULL. Matching is case-insensitive (Enum.valueOf after upper-casing); any other string throws this IllegalArgumentException, returned to the client as HTTP 400.","triggerScenarios":"POST ?op=APPENDFILE (typo); POST ?op=SETSTORAGEPOLICY (a PUT op — must not be POSTed); POST ?op=CONCAT missing valid sources; POST ?op=UNSETECPOLICY on an older Hadoop that lacks EC support; any op from the GET/PUT/DELETE families sent with the POST verb.","commonSituations":"The storage-policy and EC unset operations moved verb families between docs versions (some examples show PUT); hand-rolled REST clients hard-coding the wrong verb; CONCAT workflows where the sources list is built dynamically and the op string is templated.","solutions":["Use exactly APPEND, CONCAT, TRUNCATE, UNSETECPOLICY or UNSETSTORAGEPOLICY as the op value on POST.","Move misplaced ops to the right verb: SETSTORAGEPOLICY/SETECPOLICY are PUT; their UNSET twins are POST.","If the request is from the Java client, upgrade hadoop-hdfs-client to match the server — the client emits correct verb/op pairs.","Echo the failing URL in your logs to spot template typos immediately."],"exampleFix":"# before\ncurl -i -X POST \"http://nn:9870/webhdfs/v1/f?op=SETSTORAGEPOLICY\"\n# after\ncurl -i -X PUT  \"http://nn:9870/webhdfs/v1/f?op=SETSTORAGEPOLICY&policyname=HOT\"\ncurl -i -X POST \"http://nn:9870/webhdfs/v1/f?op=UNSETSTORAGEPOLICY\"","handlingStrategy":"validation","validationCode":"private static final Set<String> POST_OPS = Set.of(\"APPEND\",\"CONCAT\",\"TRUNCATE\",\"UNSETECPOLICY\",\"UNSETSTORAGEPOLICY\");\nstatic String checkedPostOp(String op) {\n  String v = op.toUpperCase(Locale.ROOT);\n  if (!POST_OPS.contains(v)) throw new IllegalArgumentException(\"op must be one of \" + POST_OPS + \": \" + op);\n  return v;\n}","typeGuard":"static boolean isValidPostOp(String op) {\n  return op != null && Set.of(\"APPEND\",\"CONCAT\",\"TRUNCATE\",\"UNSETECPOLICY\",\"UNSETSTORAGEPOLICY\").contains(op.toUpperCase(Locale.ROOT));\n}","tryCatchPattern":null,"preventionTips":["Remember UNSET* policy ops are POST while SET* are PUT.","Maintain one verb+op table for all WebHDFS calls and assert against it in tests."],"tags":["webhdfs","http-post","query-param","hdfs","rest-api"],"backgroundTag":"webhdfs-invalid-op-parameter","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}