apache/hadoop · error · IllegalArgumentException
{str} is not a valid GET operation.
Error message
{str} is not a valid GET operation. What it means
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.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/GetOpParam.java:135
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 GetOpParam(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.GET
+ " operation.");
}
}
@Override
public String getName() {
return NAME;
}
}
View on GitHub (pinned to 2add963021)
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.
Example fix
# before curl -i "http://nn:9870/webhdfs/v1/tmp/f?op=GETFILESTAT" # after curl -i "http://nn:9870/webhdfs/v1/tmp/f?op=GETFILESTATUS"
Defensive patterns
Strategy: validation
Validate before calling
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");
static String checkedGetOp(String op) {
String v = op.toUpperCase(Locale.ROOT);
if (!GET_OPS.contains(v)) throw new IllegalArgumentException("unsupported GET op for this cluster: " + op);
return v;
} Type guard
static boolean isSupportedGetOp(String op, Set<String> supported) {
return op != null && supported.contains(op.toUpperCase(Locale.ROOT));
} Try / catch
try { ... } catch (IOException e) {
RemoteException re = (RemoteException) (e instanceof RemoteException ? e : null);
if (re != null && re.getClassName().endsWith("IllegalArgumentException") && re.getMessage().contains("valid GET operation")) {
// typo or version drift: cross-check op against the cluster's hadoop version
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {str} is not a valid DELETE 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/0c456f511ed5ec21.
Report an issue: GitHub.