{"record":{"id":"001d4c197ec60b5a","repo":"apache/hadoop","slug":"invalid-mode-argument","errorCode":null,"errorMessage":"Invalid mode: {argument}","messagePattern":"Invalid mode: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/find/Perm.java","lineNumber":101,"sourceCode":"        int shift;\n        Operator operator = null;\n        int value = 0;\n        int position = 0;\n        switch (part.charAt(position++)) {\n        case 'u':\n          shift = 6;\n          break;\n        case 'g':\n          shift = 3;\n          break;\n        case 'o':\n          shift = 0;\n          break;\n        case 'a':\n          shift = -1;\n          break;\n        default:\n          throw new IllegalArgumentException(\"Invalid mode: \" + argument);\n        }\n        outer:\n        while (position < part.length()) {\n          switch (part.charAt(position++)) {\n          case '=':\n            operator = EQUALS;\n            break;\n          case '+':\n            operator = PLUS;\n            break;\n          case '-':\n            operator = MINUS;\n            break;\n          default:\n            throw new IllegalArgumentException(\"Invalid mode: \" + argument);\n          }\n          value = 0;\n          while (position < part.length()) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/find/Perm.java#L83-L119","documentation":"For a symbolic '-perm' argument, Perm.parseArgument() splits on ',' and requires each part to begin with a 'who' character: 'u' (user, shift 6), 'g' (group, shift 3), 'o' (other, shift 0) or 'a' (all, shift -1). Any other first character reaches the default branch and throws IllegalArgumentException('Invalid mode: <argument>') carrying the full original argument.","triggerScenarios":"'hadoop fs find / -perm rwx' (who prefix missing), '-perm z+x', or '-perm user+r' (a word instead of the single letters u/g/o/a). Numeric arguments take a different path and must start with a digit.","commonSituations":"Copying chmod-style examples that omit the who class; mode strings assembled at runtime by concatenation; expecting GNU find extensions to be supported.","solutions":["Prefix every comma-separated part with u, g, o or a (e.g. 'u=rw,g=r')","Validate each part against ^[ugoa][+-=][rwx]+$ before passing it","Prefer the numeric form ('-perm 644') when the exact mask is known"],"exampleFix":"# before\nhadoop fs find /data -perm rwx\n\n# after\nhadoop fs find /data -perm a=rwx","handlingStrategy":"validation","validationCode":"static boolean isValidSymbolicMode(String arg) {\n  if (arg == null || arg.isEmpty()) return false;\n  String a = arg.startsWith(\"-\") ? arg.substring(1) : arg;\n  if (a.isEmpty() || Character.isDigit(a.charAt(0))) return !a.isEmpty(); // numeric ok\n  for (String p : a.split(\",\")) {\n    if (!p.matches(\"[ugoa][+-=][rwx]+\")) return false;\n  }\n  return true;\n}","typeGuard":null,"tryCatchPattern":"Catch IllegalArgumentException around the find invocation; all three symbolic-mode failures share the 'Invalid mode: <argument>' message, so include the raw mode string in the rethrown error.","preventionTips":["Start each comma part with u, g, o or a","Never pass a bare rwx string","Prefer octal modes (-perm 644) for exact masks"],"tags":["hadoop","fs-shell","find","permissions","symbolic-mode","argument-validation"],"backgroundTag":"invalid-permission-mode","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}