{"record":{"id":"79b5f6adb3fc0fb7","repo":"apache/hadoop","slug":"s-is-not-a-valid-runstate","errorCode":null,"errorMessage":"%s is not a valid runState.","messagePattern":"(.+?) is not a valid runState\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/commit/mapred/Committer.java","lineNumber":132,"sourceCode":"    getWrapped(context).cleanupJob(context);\n  }\n\n  @Override\n  public void abortJob(JobContext context, int runState)\n      throws IOException {\n    JobStatus.State state;\n    if(runState == JobStatus.State.RUNNING.getValue()) {\n      state = JobStatus.State.RUNNING;\n    } else if(runState == JobStatus.State.SUCCEEDED.getValue()) {\n      state = JobStatus.State.SUCCEEDED;\n    } else if(runState == JobStatus.State.FAILED.getValue()) {\n      state = JobStatus.State.FAILED;\n    } else if(runState == JobStatus.State.PREP.getValue()) {\n      state = JobStatus.State.PREP;\n    } else if(runState == JobStatus.State.KILLED.getValue()) {\n      state = JobStatus.State.KILLED;\n    } else {\n      throw new IllegalArgumentException(runState+\" is not a valid runState.\");\n    }\n    getWrapped(context).abortJob(context, state);\n  }\n\n  @Override\n  public void setupTask(TaskAttemptContext context) throws IOException {\n    getWrapped(context).setupTask(context);\n  }\n\n  @Override\n  public void commitTask(TaskAttemptContext context) throws IOException {\n    getWrapped(context).commitTask(context);\n  }\n\n  @Override\n  public void abortTask(TaskAttemptContext context) throws IOException {\n    getWrapped(context).abortTask(context);\n  }","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/commit/mapred/Committer.java#L114-L150","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass only values derived from JobStatus.State (e.g. JobStatus.State.FAILED.getValue()) or the legacy JobStatus constants","Migrate the caller from the deprecated mapred abortJob(JobContext, int) to the mapreduce abortJob(JobContext, JobStatus.State) API, which is type-safe","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"],"exampleFix":"// before\ncommitter.abortJob(context, 6); // IllegalArgumentException: 6 is not a valid runState.\n// after\ncommitter.abortJob(context, org.apache.hadoop.mapred.JobStatus.FAILED);","handlingStrategy":"validation","validationCode":"static boolean isValidRunState(int runState) {\n  return Arrays.stream(JobStatus.State.values()).anyMatch(s -> s.getValue() == runState);\n}\n\nif (!isValidRunState(runState)) {\n  throw new IllegalArgumentException(\"Unsupported runState: \" + runState\n      + \"; expected one of \" + Arrays.toString(JobStatus.State.values()));\n}","typeGuard":"static Optional<JobStatus.State> runStateOf(int runState) {\n  return Arrays.stream(JobStatus.State.values())\n      .filter(s -> s.getValue() == runState)\n      .findFirst();\n}","tryCatchPattern":"try {\n  committer.abortJob(context, runState);\n} catch (IllegalArgumentException e) {\n  // unknown state code: degrade to a safe default instead of failing cleanup\n  LOG.warn(\"Unknown runState \" + runState + \"; aborting as KILLED\", e);\n  committer.abortJob(context, JobStatus.State.KILLED.getValue());\n}","preventionTips":["Always pass JobStatus constants (JobStatus.FAILED/KILLED/...) instead of raw ints","Prefer the type-safe mapreduce API abortJob(JobContext, JobStatus.State) over the deprecated mapred int variant","Never invent custom run-state codes; if a new state exists in your Hadoop fork, map it to FAILED or KILLED at the boundary","Unit-test abortJob paths with all five legal states plus one illegal value"],"tags":["hadoop","mapred","job-status","tos","enum-mapping"],"backgroundTag":"invalid-enum-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}