apache/hadoop · error · ExitUtil.ExitException

42

42

Error message

Wrong number of arguments: %d

What it means

The markers tool requires exactly one non-option argument: the path to scan. run() checks parsedArgs.size() != 1, prints the usage plus the supplied argument list, and throws ExitUtil.ExitException EXIT_USAGE (42) with 'Wrong number of arguments: <count>' (constant E_ARGUMENTS).

Source

Thrown at hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/tools/MarkerTool.java:240

  @Override
  public void resetBindings() {
    super.resetBindings();
    storeContext = null;
    operations = null;
  }

  @Override
  public int run(final String[] args, final PrintStream stream)
      throws ExitUtil.ExitException, Exception {
    this.out = stream;
    final List<String> parsedArgs = parseArgsWithErrorReporting(args);
    if (parsedArgs.size() != 1) {
      errorln(getUsage());
      println(out, "Supplied arguments: ["
          + String.join(", ", parsedArgs)
          + "]");
      throw new ExitUtil.ExitException(EXIT_USAGE,
          String.format(E_ARGUMENTS, parsedArgs.size()));
    }
    // read arguments
    CommandFormat command = getCommandFormat();
    verbose = command.getOpt(VERBOSE);

    // minimum number of markers expected
    int expectedMin = getOptValue(OPT_MIN, 0);
    // max number of markers allowed
    int expectedMax = getOptValue(OPT_MAX, 0);


    // determine the action
    boolean audit = command.getOpt(OPT_AUDIT);
    boolean clean = command.getOpt(OPT_CLEAN);
    if (audit == clean) {
      // either both are set or neither are set
      // this is equivalent to (not audit xor clean)

View on GitHub (pinned to 2add963021)

Solutions

  1. Supply exactly one path: 'hadoop aws s3guard markers -audit s3a://bucket/path'
  2. Re-check that every value-taking option (-min, -max, -limit, -out) is followed by its value so token counting works out
  3. Read the tool's own output - it prints the supplied arguments list, which shows exactly which stray or missing token caused the count mismatch

Example fix

# before
hadoop aws s3guard markers -audit
# after
hadoop aws s3guard markers -audit s3a://my-bucket/tables
Defensive patterns

Strategy: validation

Validate before calling

List<String> nonOption = extractNonOptionArgs(args); // same rules as CommandFormat
if (nonOption.size() != 1) {
  System.err.println("markers requires exactly one path, got " + nonOption.size());
  return 42;
}

Try / catch

try {
  int rc = new MarkerTool(conf).exec(args);
} catch (ExitUtil.ExitException e) {
  if (e.getMessage().startsWith("Wrong number of arguments")) {
    // re-print usage and the parsed argument list, then correct the invocation
  }
}

Prevention

When it happens

Trigger: 'markers -audit' with no path; two or more non-option tokens (e.g. 'markers -audit s3a://a s3a://b'); a value-taking option (-min, -max, -limit, -out) given without its value so the next token is consumed or a stray token survives.

Common situations: Forgetting the path; wrappers appending extra arguments; options whose value was accidentally dropped during script refactoring.

Related errors


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