apache/hadoop · error · HadoopIllegalArgumentException

No arguments specified

Error message

No arguments specified

What it means

LogLevel.CLI.parseArguments rejects an empty argument vector immediately: the log-level tool must be told what to do (-getlevel or -setlevel) and where (host:port, classname). HadoopIllegalArgumentException is thrown, run() prints usage, and the CLI exits with -1. No network activity happens — this is pure argument validation.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java:144

    private void sendLogLevelRequest()
        throws HadoopIllegalArgumentException, Exception {
      switch (operation) {
      case GETLEVEL:
        doGetLevel();
        break;
      case SETLEVEL:
        doSetLevel();
        break;
      default:
        throw new HadoopIllegalArgumentException(
          "Expect either -getlevel or -setlevel");
      }
    }

    public void parseArguments(String[] args) throws
        HadoopIllegalArgumentException {
      if (args.length == 0) {
        throw new HadoopIllegalArgumentException("No arguments specified");
      }
      int nextArgIndex = 0;
      while (nextArgIndex < args.length) {
        if (args[nextArgIndex].equals("-getlevel")) {
          nextArgIndex = parseGetLevelArgs(args, nextArgIndex);
        } else if (args[nextArgIndex].equals("-setlevel")) {
          nextArgIndex = parseSetLevelArgs(args, nextArgIndex);
        } else if (args[nextArgIndex].equals("-protocol")) {
          nextArgIndex = parseProtocolArgs(args, nextArgIndex);
        } else {
          throw new HadoopIllegalArgumentException(
              "Unexpected argument " + args[nextArgIndex]);
        }
      }

      // if operation is never specified in the arguments
      if (operation == Operations.UNKNOWN) {
        throw new HadoopIllegalArgumentException(

View on GitHub (pinned to 2add963021)

Solutions

  1. Supply valid options, e.g. 'hadoop loglevel -getlevel namenode:9870 org.apache.hadoop.ipc.Server'.
  2. Fix the wrapper script: default the args variable ('${ARGS:-}') and guard against empty expansion before invoking the tool.
  3. Run 'hadoop loglevel' with no args intentionally to print usage when unsure of the syntax.

Example fix

# before
hadoop loglevel $EMPTY_VAR

# after
hadoop loglevel -getlevel namenode:9870 org.apache.hadoop.ipc.Server
Defensive patterns

Strategy: validation

Validate before calling

// In wrappers: refuse to invoke the tool on empty input
if (args == null || args.length == 0) {
  System.err.println(LogLevel.USAGES);
  return 1;
}
return ToolRunner.run(new LogLevel.CLI(conf), args);

Prevention

When it happens

Trigger: Running 'hadoop loglevel' (or 'hadoop org.apache.hadoop.log.LogLevel') with zero arguments; invoking ToolRunner.run(new CLI(conf), new String[0]); a wrapper script that forwards an unset variable, e.g., $ARGS expanding to nothing.

Common situations: Shell scripts calling the tool with unquoted/unset variables; CI jobs constructing the command dynamically from empty input; users probing the tool's behavior with no args.

Related errors


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