apache/hadoop · error · HadoopIllegalArgumentException
Specified flags contains both remove and modify flags
Error message
Specified flags contains both remove and modify flags
What it means
Setfacl.processOptions throws HadoopIllegalArgumentException when the invocation mixes mutually exclusive operation modes: both -b and -k (remove-all/remove-default), both -m and -x (modify/remove-entries), any remove flag together with a modify flag, or --set combined with -b/-k/-m/-x. Each run must perform exactly one kind of ACL operation.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java:204
List<AclEntry> accessAclEntries = null;
@Override
protected void processOptions(LinkedList<String> args) throws IOException {
cf.parse(args);
setRecursive(cf.getOpt("R"));
// Mix of remove and modify acl flags are not allowed
boolean bothRemoveOptions = cf.getOpt("b") && cf.getOpt("k");
boolean bothModifyOptions = cf.getOpt("m") && cf.getOpt("x");
boolean oneRemoveOption = cf.getOpt("b") || cf.getOpt("k");
boolean oneModifyOption = cf.getOpt("m") || cf.getOpt("x");
boolean setOption = cf.getOpt("-set");
boolean hasExpectedOptions = cf.getOpt("b") || cf.getOpt("k") ||
cf.getOpt("m") || cf.getOpt("x") || cf.getOpt("-set");
if ((bothRemoveOptions || bothModifyOptions)
|| (oneRemoveOption && oneModifyOption)
|| (setOption && (oneRemoveOption || oneModifyOption))) {
throw new HadoopIllegalArgumentException(
"Specified flags contains both remove and modify flags");
}
// Only -m, -x and --set expects <acl_spec>
if (oneModifyOption || setOption) {
if (args.isEmpty()) {
throw new HadoopIllegalArgumentException(
"Missing arguments: <acl_spec> <path>");
}
if (args.size() < 2) {
throw new HadoopIllegalArgumentException(
"Missing either <acl_spec> or <path>");
}
aclEntries = AclEntry.parseAclSpec(args.removeFirst(), !cf.getOpt("x"));
if (aclEntries.isEmpty()) {
throw new HadoopIllegalArgumentException(
"Missing <acl_spec> entry");
}View on GitHub (pinned to 2add963021)
Solutions
- Split into sequential invocations: hadoop fs -setfacl -b /p && hadoop fs -setfacl -m user:bob:rw- /p.
- Use --set with a complete ACL spec to define the final state in one shot instead of mixing removal and modification flags.
Example fix
# before hadoop fs -setfacl -b -m user:bob:rw- /data # after hadoop fs -setfacl -b /data hadoop fs -setfacl -m user:bob:rw- /data
Defensive patterns
Strategy: validation
Validate before calling
# one mode per invocation: -b, -k, -m <spec>, -x <spec>, or --set <spec> hadoop fs -setfacl -b /data && hadoop fs -setfacl -m user:bob:rw- /data
Prevention
- Treat each setfacl run as exactly one ACL operation.
- Use --set with a full spec to reach a desired end state in one command.
When it happens
Trigger: 'hadoop fs -setfacl -b -m user:bob:rw- /path', 'hadoop fs -setfacl --set user::rw- -x user:carol /path', or 'hadoop fs -setfacl -k -b /path' — any combination the flag-matrix in AclCommands.java:204 rejects.
Common situations: Porting muscle memory from chmod-style option chaining; attempting to 'reset then modify' an ACL in a single command instead of two sequential commands or one --set.
Related errors
- Missing arguments: <acl_spec> <path>
- Missing either <acl_spec> or <path>
- Missing <acl_spec> entry
- Expected one of -b, -k, -m, -x or --set options
- <path> is missing
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/28f78c7411d5ec71.
Report an issue: GitHub.