{"record":{"id":"28f78c7411d5ec71","repo":"apache/hadoop","slug":"specified-flags-contains-both-remove-and-modify-fl","errorCode":null,"errorMessage":"Specified flags contains both remove and modify flags","messagePattern":"Specified flags contains both remove and modify flags","errorType":"exception","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java","lineNumber":204,"sourceCode":"    List<AclEntry> accessAclEntries = null;\n\n    @Override\n    protected void processOptions(LinkedList<String> args) throws IOException {\n      cf.parse(args);\n      setRecursive(cf.getOpt(\"R\"));\n      // Mix of remove and modify acl flags are not allowed\n      boolean bothRemoveOptions = cf.getOpt(\"b\") && cf.getOpt(\"k\");\n      boolean bothModifyOptions = cf.getOpt(\"m\") && cf.getOpt(\"x\");\n      boolean oneRemoveOption = cf.getOpt(\"b\") || cf.getOpt(\"k\");\n      boolean oneModifyOption = cf.getOpt(\"m\") || cf.getOpt(\"x\");\n      boolean setOption = cf.getOpt(\"-set\");\n      boolean hasExpectedOptions = cf.getOpt(\"b\") || cf.getOpt(\"k\") ||\n          cf.getOpt(\"m\") || cf.getOpt(\"x\") || cf.getOpt(\"-set\");\n\n      if ((bothRemoveOptions || bothModifyOptions)\n          || (oneRemoveOption && oneModifyOption)\n          || (setOption && (oneRemoveOption || oneModifyOption))) {\n        throw new HadoopIllegalArgumentException(\n            \"Specified flags contains both remove and modify flags\");\n      }\n\n      // Only -m, -x and --set expects <acl_spec>\n      if (oneModifyOption || setOption) {\n        if (args.isEmpty()) {\n          throw new HadoopIllegalArgumentException(\n              \"Missing arguments: <acl_spec> <path>\");\n        }\n        if (args.size() < 2) {\n          throw new HadoopIllegalArgumentException(\n              \"Missing either <acl_spec> or <path>\");\n        }\n        aclEntries = AclEntry.parseAclSpec(args.removeFirst(), !cf.getOpt(\"x\"));\n        if (aclEntries.isEmpty()) {\n          throw new HadoopIllegalArgumentException(\n              \"Missing <acl_spec> entry\");\n        }","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java#L186-L222","documentation":"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.","triggerScenarios":"'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.","commonSituations":"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.","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."],"exampleFix":"# before\nhadoop fs -setfacl -b -m user:bob:rw- /data\n\n# after\nhadoop fs -setfacl -b /data\nhadoop fs -setfacl -m user:bob:rw- /data","handlingStrategy":"validation","validationCode":"# one mode per invocation: -b, -k, -m <spec>, -x <spec>, or --set <spec>\nhadoop fs -setfacl -b /data && hadoop fs -setfacl -m user:bob:rw- /data","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat each setfacl run as exactly one ACL operation.","Use --set with a full spec to reach a desired end state in one command."],"tags":["cli","setfacl","acl","conflicting-flags","hadoop"],"backgroundTag":"conflicting-cli-flags","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}