apache/hadoop · error · IllegalArgumentException
chmod : mode '" + modeStr + "' does not match the expected…
Error message
chmod : mode '" + modeStr + "' does not match the expected pattern.
What it means
Thrown by FsShellPermissions.Chmod.processOptions when ChmodParser rejects the mode string with IllegalArgumentException. The mode expression (octal or symbolic) does not match the expected chmod pattern and is rethrown with context.
Solutions
- Use an octal mode like 755 or a symbolic mode like u+rwx matching chmod syntax.
- Quote the mode argument to prevent shell mangling.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShellPermissions.java:93 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/95624892e76e9887.
Report an issue: GitHub.
Appendix: source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShellPermissions.java:93
"mode, e.g. 754 is same as u=rwx,g=rx,o=r.\n\n" +
"If none of 'augo' is specified, 'a' is assumed and unlike the " +
"shell command, no umask is applied.";
protected ChmodParser pp;
@Override
protected void processOptions(LinkedList<String> args) throws IOException {
CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "R", null);
cf.parse(args);
setRecursive(cf.getOpt("R"));
String modeStr = args.removeFirst();
try {
pp = new ChmodParser(modeStr);
} catch (IllegalArgumentException iea) {
// TODO: remove "chmod : " so it's not doubled up in output, but it's
// here for backwards compatibility...
throw new IllegalArgumentException(
"chmod : mode '" + modeStr + "' does not match the expected pattern.");
}
}
@Override
protected void processPath(PathData item) throws IOException {
short newperms = pp.applyNewPermission(item.stat);
if (item.stat.getPermission().toShort() != newperms) {
try {
item.fs.setPermission(item.path, new FsPermission(newperms));
} catch (IOException e) {
LOG.debug("Error changing permissions of " + item, e);
throw new IOException(
"changing permissions of '" + item + "': " + e.getMessage());
}
}
}
}View on GitHub (pinned to 2add963021)