{"record":{"id":"606235590d928383","repo":"apache/hadoop","slug":"str-is-not-a-valid-delete-operation","errorCode":null,"errorMessage":"{str} is not a valid DELETE operation.","messagePattern":"(.+?) is not a valid DELETE 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/DeleteOpParam.java","lineNumber":82,"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 DeleteOpParam(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.DELETE\n          + \" operation.\");\n    }\n  }\n\n  @Override\n  public String getName() {\n    return NAME;\n  }\n}\n","sourceCodeStart":64,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/DeleteOpParam.java#L64-L92","documentation":"DeleteOpParam parses the 'op' query parameter of a WebHDFS/HttpFS HTTP DELETE request against the enum {DELETE, DELETESNAPSHOT, NULL} (see DeleteOpParam.java:25-29). Parsing uses Enum.valueOf with toUpperCase, so matching is case-insensitive, but any string that is not one of those enum constants is rejected with this IllegalArgumentException, which the server translates into an HTTP 400 response. It exists to stop clients from invoking an operation that the DELETE verb does not carry.","triggerScenarios":"DELETE http://nn:9870/webhdfs/v1/tmp/f?op=DELETEFILE (typo), ?op=RMDIR, ?op=DELETE_SNAPSHOT, or sending an op belonging to another verb family with DELETE, e.g. ?op=RENAME or ?op=APPEND on a DELETE request. Any DELETE call whose op value is not exactly DELETE, DELETESNAPSHOT or NULL (after upper-casing) triggers it.","commonSituations":"Hand-built REST URLs in curl/scripts with misspelled op names; porting raw-HTTP examples between WebHDFS versions (DELETESNAPSHOT requires a snapshot-capable Hadoop 2.x+); copy-pasting an op value from a PUT example into a DELETE call; URL templates built from user input where the op slot is empty or mangled.","solutions":["Set op=DELETE (or op=DELETESNAPSHOT with a valid snapshotname parameter) in the query string of the DELETE request.","Check the HTTP verb matches the op family: delete-file is DELETE+DELETE, snapshot removal is DELETE+DELETESNAPSHOT.","If you are constructing URLs by hand, prefer the WebHFileSystem Java client or 'hadoop fs -ls webhdfs://...' / 'hadoop fs -rm' which emit correct op values.","Log the full URL you send and compare the op token letter-by-letter with the enum values in DeleteOpParam.java:25."],"exampleFix":"# before\ncurl -i -X DELETE \"http://nn:9870/webhdfs/v1/tmp/f?op=DELETEFILE&user.name=hdfs\"\n# after\ncurl -i -X DELETE \"http://nn:9870/webhdfs/v1/tmp/f?op=DELETE&user.name=hdfs\"","handlingStrategy":"validation","validationCode":"private static final Set<String> VALID_DELETE_OPS = Set.of(\"DELETE\", \"DELETESNAPSHOT\");\nstatic String checkedDeleteOp(String op) {\n  String v = op == null ? null : op.toUpperCase(Locale.ROOT);\n  if (!VALID_DELETE_OPS.contains(v)) throw new IllegalArgumentException(\"op must be one of \" + VALID_DELETE_OPS + \": \" + op);\n  return v;\n}","typeGuard":"static boolean isValidDeleteOp(String op) {\n  return op != null && Set.of(\"DELETE\", \"DELETESNAPSHOT\").contains(op.toUpperCase(Locale.ROOT));\n}","tryCatchPattern":"try {\n  resp = http.delete(buildWebhdfsUrl(path, \"DELETE\"));\n} catch (IOException e) {\n  if (e instanceof RemoteException re && re.getClassName().endsWith(\"IllegalArgumentException\")) {\n    // bad op token: fix the URL template, do not retry\n  }\n}","preventionTips":["Centralize op-string constants in one enum mirroring DeleteOpParam.Op instead of scattering literals.","Log the full outgoing WebHDFS URL at DEBUG so typos are visible immediately.","Prefer the webhdfs:// Java FileSystem client over hand-built URLs."],"tags":["webhdfs","http-delete","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"}