apache/hadoop · warning · HadoopIllegalArgumentException

Illegal argument: ${arg}

Error message

Illegal argument: ${arg}

What it means

BootstrapStandby.parseArgs() accepts exactly -force, -nonInteractive and -skipSharedEditsCheck; any other token prints usage and throws HadoopIllegalArgumentException('Illegal argument: <arg>'). It is a pure command-line usage error for 'hdfs namenode -bootstrapStandby'.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/BootstrapStandby.java:144

          return doRun();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
    });
  }
  
  private void parseArgs(String[] args) {
    for (String arg : args) {
      if ("-force".equals(arg)) {
        force = true;
      } else if ("-nonInteractive".equals(arg)) {
        interactive = false;
      } else if ("-skipSharedEditsCheck".equals(arg)) {
        skipSharedEditsCheck = true;
      } else {
        printUsage();
        throw new HadoopIllegalArgumentException(
            "Illegal argument: " + arg);
      }
    }
  }

  private void printUsage() {
    System.out.println("Usage: " + this.getClass().getSimpleName() +
        " [-force] [-nonInteractive] [-skipSharedEditsCheck]\n"
        + "\t-force: formats if the name directory exists.\n"
        + "\t-nonInteractive: formats aborts if the name directory exists,\n"
        + "\tunless -force option is specified.\n"
        + "\t-skipSharedEditsCheck: skips edits check which ensures that\n"
        + "\twe have enough edits already in the shared directory to start\n"
        + "\tup from the last checkpoint on the active.");
  }

  private NamenodeProtocol createNNProtocolProxy(InetSocketAddress otherIpcAddr)
      throws IOException {

View on GitHub (pinned to 2add963021)

Solutions

  1. Re-run with only supported flags: hdfs namenode -bootstrapStandby [-force] [-nonInteractive] [-skipSharedEditsCheck]
  2. Check for typos and shell expansion in the failing argument (echo the command before running)
  3. Run 'hdfs namenode -help' for this release's actual flag list

Example fix

# before
$ hdfs namenode -bootstrapStandby -forceFormats
Illegal argument: -forceFormats
# after
$ hdfs namenode -bootstrapStandby -force
Defensive patterns

Strategy: validation

Validate before calling

Set<String> allowed = Set.of("-force", "-nonInteractive", "-skipSharedEditsCheck");
for (String arg : args) {
  if (!allowed.contains(arg)) {
    System.err.println("Usage: hdfs namenode -bootstrapStandby [-force] "
        + "[-nonInteractive] [-skipSharedEditsCheck]");
    System.exit(1); // fail fast with usage instead of deep exception
  }
}

Try / catch

try {
  BootstrapStandby runner = new BootstrapStandby(conf, ...);
} catch (HadoopIllegalArgumentException e) { // "Illegal argument: X"
  // pure usage error: print usage, exit non-zero; no retry needed
}

Prevention

When it happens

Trigger: Running 'hdfs namenode -bootstrapStandby <anything-else>' — a typo like -forces or -noniteractive, a flag belonging to another subcommand (-format, -rollUpgrade), or a stray argument after the subcommand.

Common situations: Operators copy a flag from another namenode subcommand; shell scripts pass unquoted variables that expand to unexpected tokens; documentation from a different Hadoop version mentions a flag that does not exist here.

Related errors


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