apache/hadoop · error · HadoopIllegalArgumentException

args = {}

Error message

args = {}

What it means

Thrown as HadoopIllegalArgumentException by FsImageValidation's Cli.parse when args.length > 1. The tool accepts at most one argument (the fsimage path); anything else — extra flags, multiple image paths, or a path with spaces split by the shell — is rejected with "args = [..]" listing what it received.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FsImageValidation.java:355

    @Override
    public int run(String[] args) throws Exception {
      initLogLevels();

      final FsImageValidation validation = FsImageValidation.newInstance(args);
      final AtomicInteger errorCount = new AtomicInteger();
      validation.run(getConf(), errorCount);
      println("Error Count: %s", errorCount);
      return errorCount.get() == 0? 0: 1;
    }

    static String parse(String... args) {
      final String f;
      if (args == null || args.length == 0) {
        f = getEnv(FS_IMAGE);
      } else if (args.length == 1) {
        f = args[0];
      } else {
        throw new HadoopIllegalArgumentException(
            "args = " + Arrays.toString(args));
      }

      println("%s = %s", FS_IMAGE, f);
      return f;
    }

    static synchronized void println(String format, Object... args) {
      final String s = String.format(format, args);
      System.out.println(s);
      LOG.info(s);
    }

    static synchronized void warn(String format, Object... args) {
      final String s = "WARN: " + String.format(format, args);
      System.out.println(s);
      LOG.warn(s);
    }

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass exactly one argument: the fsimage file path
  2. Quote paths that contain spaces: "/opt/hadoop data/fsimage_0000000000000012345"
  3. Or pass no arguments at all and rely on the FS_IMAGE environment variable

Example fix

# before
hdfs org.apache.hadoop.hdfs.server.namenode.FsImageValidation /a/fsimage_1 /b/fsimage_2
# -> HadoopIllegalArgumentException: args = [/a/fsimage_1, /b/fsimage_2]

# after
hdfs org.apache.hadoop.hdfs.server.namenode.FsImageValidation /a/fsimage_1
hdfs org.apache.hadoop.hdfs.server.namenode.FsImageValidation /b/fsimage_2
Defensive patterns

Strategy: validation

Validate before calling

if (args == null) { args = new String[0]; }
if (args.length > 1) {
  throw new IllegalArgumentException(
      "Expected exactly one fsimage path, got: " + Arrays.toString(args));
}
FsImageValidation.newInstance(args.length == 1 ? args[0] : System.getenv("FS_IMAGE"));

Prevention

When it happens

Trigger: Passing two fsimage paths to validate in one run; adding unsupported flags like -h or --verbose next to the path; an unquoted path containing spaces so the shell expands it into multiple argv entries.

Common situations: Shell scripts that append options the tool never supported; copy-pasted commands with trailing parameters; whitespace in the fsimage directory name without quotes.

Related errors


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