apache/hadoop · error · IllegalArgumentException

%s is not a valid runState.

Error message

%s is not a valid runState.

What it means

The old mapred-API adapter (org.apache.hadoop.fs.tosfs.commit.mapred.Committer.abortJob) translates the int runState argument into a JobStatus.State and rejects any value outside the five known states (RUNNING=1, SUCCEEDED=2, FAILED=3, PREP=4, KILLED=5). An unrecognized int means the caller passed a state this Hadoop version does not know, or an arbitrary number.

Source

Thrown at hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/commit/mapred/Committer.java:132

    getWrapped(context).cleanupJob(context);
  }

  @Override
  public void abortJob(JobContext context, int runState)
      throws IOException {
    JobStatus.State state;
    if(runState == JobStatus.State.RUNNING.getValue()) {
      state = JobStatus.State.RUNNING;
    } else if(runState == JobStatus.State.SUCCEEDED.getValue()) {
      state = JobStatus.State.SUCCEEDED;
    } else if(runState == JobStatus.State.FAILED.getValue()) {
      state = JobStatus.State.FAILED;
    } else if(runState == JobStatus.State.PREP.getValue()) {
      state = JobStatus.State.PREP;
    } else if(runState == JobStatus.State.KILLED.getValue()) {
      state = JobStatus.State.KILLED;
    } else {
      throw new IllegalArgumentException(runState+" is not a valid runState.");
    }
    getWrapped(context).abortJob(context, state);
  }

  @Override
  public void setupTask(TaskAttemptContext context) throws IOException {
    getWrapped(context).setupTask(context);
  }

  @Override
  public void commitTask(TaskAttemptContext context) throws IOException {
    getWrapped(context).commitTask(context);
  }

  @Override
  public void abortTask(TaskAttemptContext context) throws IOException {
    getWrapped(context).abortTask(context);
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass only values derived from JobStatus.State (e.g. JobStatus.State.FAILED.getValue()) or the legacy JobStatus constants
  2. Migrate the caller from the deprecated mapred abortJob(JobContext, int) to the mapreduce abortJob(JobContext, JobStatus.State) API, which is type-safe
  3. If a newer run state must cross into this committer, map it to the closest supported state (e.g. a new failure variant -> FAILED) before calling abortJob

Example fix

// before
committer.abortJob(context, 6); // IllegalArgumentException: 6 is not a valid runState.
// after
committer.abortJob(context, org.apache.hadoop.mapred.JobStatus.FAILED);
Defensive patterns

Strategy: validation

Validate before calling

static boolean isValidRunState(int runState) {
  return Arrays.stream(JobStatus.State.values()).anyMatch(s -> s.getValue() == runState);
}

if (!isValidRunState(runState)) {
  throw new IllegalArgumentException("Unsupported runState: " + runState
      + "; expected one of " + Arrays.toString(JobStatus.State.values()));
}

Type guard

static Optional<JobStatus.State> runStateOf(int runState) {
  return Arrays.stream(JobStatus.State.values())
      .filter(s -> s.getValue() == runState)
      .findFirst();
}

Try / catch

try {
  committer.abortJob(context, runState);
} catch (IllegalArgumentException e) {
  // unknown state code: degrade to a safe default instead of failing cleanup
  LOG.warn("Unknown runState " + runState + "; aborting as KILLED", e);
  committer.abortJob(context, JobStatus.State.KILLED.getValue());
}

Prevention

When it happens

Trigger: Calling org.apache.hadoop.mapred.OutputCommitter.abortJob(JobContext, int) through the mapred adapter with an int that matches no JobStatus.State value, e.g. 0, 6, or a custom code from a homegrown JobClient, JobControl, or third-party scheduler wrapper.

Common situations: Legacy mapred pipelines that hand-build runState ints instead of using JobStatus constants; forks/newer Hadoop versions that introduce additional run states and then submit to an older committer; test harnesses that pass sentinel values like -1 or 99.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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