apache/hadoop · error · IllegalArgumentException

Invalid empty argument

Error message

Invalid empty argument

What it means

Perm implements the '-perm' expression of 'hadoop fs find'. parseArgument() builds a permission mask from exactly one argument; it first rejects null, then rejects an empty string because no mode can be derived from it. The IllegalArgumentException is raised while the expression is prepared, before any path is traversed.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/find/Perm.java:71

  @Override
  public void prepare() throws IOException {
    parseArgument(getArgument(1));
  }

  /**
   * Parse an argument string to build the permission mask.
   *
   * @param argument String to be parsed
   * @throws IllegalArgumentException if the argument is invalid
   */
  private void parseArgument(String argument) throws IllegalArgumentException {
    String arg = argument;
    if (arg == null) {
      throw new IllegalArgumentException("Invalid null argument");
    }
    if (arg.isEmpty()) {
      throw new IllegalArgumentException("Invalid empty argument");
    }
    if (arg.startsWith("-")) {
      mask = true;
      arg = arg.substring(1);
    }
    if (Character.isDigit(arg.charAt(0))) {
      // the argument is a numeric mode
      permission = new FsPermission(arg).toShort();
    } else {
      // the argument is a symbolic mode
      for (String part : arg.split(",")) {
        int shift;
        Operator operator = null;
        int value = 0;
        int position = 0;
        switch (part.charAt(position++)) {
        case 'u':
          shift = 6;

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass a valid mode after -perm: numeric octal ('-perm 644') or symbolic ('-perm u=rw')
  2. Default empty shell variables: hadoop fs find / -perm "${MODE:-644}"
  3. When using the Find API programmatically, assert the argument is non-empty before addArguments()

Example fix

# before
hadoop fs find /data -perm "$PERM"   # PERM unset -> Invalid empty argument

# after
hadoop fs find /data -perm "${PERM:-644}"
Defensive patterns

Strategy: validation

Validate before calling

static boolean hasPermArgument(String arg) {
  return arg != null && !arg.isEmpty();
}
// use before building the find command:
if (!hasPermArgument(mode)) throw new IllegalArgumentException("-perm needs a mode");

Try / catch

Around Find's prepare()/execution, catch IllegalArgumentException: the -perm parser signals null, empty and malformed modes with IAE (not IOException). Wrap and rethrow with the full command line for context.

Prevention

When it happens

Trigger: Running 'hadoop fs find <path> -perm ""' (an explicitly empty quoted argument), or calling Perm.addArguments()/setArguments() programmatically with an empty string. In scripts: 'find ... -perm $MODE' where MODE is unset or empty.

Common situations: Shell scripts forwarding an unset environment variable; wrapper code that splits an options string and feeds empty tokens; users assuming '-perm' with no value means 'any permissions'.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/206b35c96341da2e. Report an issue: GitHub.