apache/hadoop · error · IllegalArgumentException
{str} is not a valid DELETE operation.
Error message
{str} is not a valid DELETE operation. What it means
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.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/DeleteOpParam.java:82
return NAME + "=" + this;
}
}
private static final Domain<Op> DOMAIN = new Domain<>(NAME, Op.class);
/**
* Constructor.
* @param str a string representation of the parameter value.
*/
public DeleteOpParam(final String str) {
super(DOMAIN, getOp(str));
}
private static Op getOp(String str) {
try {
return DOMAIN.parse(str);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(str + " is not a valid " + Type.DELETE
+ " operation.");
}
}
@Override
public String getName() {
return NAME;
}
}
View on GitHub (pinned to 2add963021)
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.
Example fix
# before curl -i -X DELETE "http://nn:9870/webhdfs/v1/tmp/f?op=DELETEFILE&user.name=hdfs" # after curl -i -X DELETE "http://nn:9870/webhdfs/v1/tmp/f?op=DELETE&user.name=hdfs"
Defensive patterns
Strategy: validation
Validate before calling
private static final Set<String> VALID_DELETE_OPS = Set.of("DELETE", "DELETESNAPSHOT");
static String checkedDeleteOp(String op) {
String v = op == null ? null : op.toUpperCase(Locale.ROOT);
if (!VALID_DELETE_OPS.contains(v)) throw new IllegalArgumentException("op must be one of " + VALID_DELETE_OPS + ": " + op);
return v;
} Type guard
static boolean isValidDeleteOp(String op) {
return op != null && Set.of("DELETE", "DELETESNAPSHOT").contains(op.toUpperCase(Locale.ROOT));
} Try / catch
try {
resp = http.delete(buildWebhdfsUrl(path, "DELETE"));
} catch (IOException e) {
if (e instanceof RemoteException re && re.getClassName().endsWith("IllegalArgumentException")) {
// bad op token: fix the URL template, do not retry
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {str} is not a valid GET operation.
- {str} is not a valid POST operation.
- {str} is not a valid PUT operation.
- Storage policy name is empty.
- {} is not supported
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/606235590d928383.
Report an issue: GitHub.