{"record":{"id":"ec0431aef6b22272","repo":"apache/hadoop","slug":"unrecognized-job-state","errorCode":null,"errorMessage":"Unrecognized job state: {}","messagePattern":"Unrecognized job state: (.+?)","errorType":"exception","errorClass":"YarnRuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/TypeConverter.java","lineNumber":403,"sourceCode":"  }\n\n\n  public static int fromYarn(JobState state) {\n    switch (state) {\n    case NEW:\n    case INITED:\n      return org.apache.hadoop.mapred.JobStatus.PREP;\n    case RUNNING:\n      return org.apache.hadoop.mapred.JobStatus.RUNNING;\n    case KILLED:\n      return org.apache.hadoop.mapred.JobStatus.KILLED;\n    case SUCCEEDED:\n      return org.apache.hadoop.mapred.JobStatus.SUCCEEDED;\n    case FAILED:\n    case ERROR:\n      return org.apache.hadoop.mapred.JobStatus.FAILED;\n    }\n    throw new YarnRuntimeException(\"Unrecognized job state: \" + state);\n  }\n\n  public static org.apache.hadoop.mapred.TIPStatus fromYarn(\n      TaskState state) {\n    switch (state) {\n    case NEW:\n    case SCHEDULED:\n      return org.apache.hadoop.mapred.TIPStatus.PENDING;\n    case RUNNING:\n      return org.apache.hadoop.mapred.TIPStatus.RUNNING;\n    case KILLED:\n      return org.apache.hadoop.mapred.TIPStatus.KILLED;\n    case SUCCEEDED:\n      return org.apache.hadoop.mapred.TIPStatus.COMPLETE;\n    case FAILED:\n      return org.apache.hadoop.mapred.TIPStatus.FAILED;\n    }\n    throw new YarnRuntimeException(\"Unrecognized task state: \" + state);","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/TypeConverter.java#L385-L421","documentation":"TypeConverter.fromYarn(JobState) maps the MRv2 job states (NEW, INITED→PREP; RUNNING; SUCCEEDED; FAILED/ERROR→FAILED; KILLED) onto classic JobStatus run-states and throws YarnRuntimeException for anything unmapped. The MRv2 JobState enum currently has exactly those seven constants, so the throw fires only when a state arrives that this build of the converter does not know — the classic version-skew signature.","triggerScenarios":"A job report from a newer MR AppMaster/JobHistory server carrying a JobState constant not present in this build's switch; mocked JobState values in tests.","commonSituations":"Down-level mapreduce-client-common talking to an upgraded cluster (rolling upgrade windows are the peak risk); third-party forks adding job states; client tools bundled with an application older than the cluster.","solutions":["Upgrade the client's hadoop-mapreduce-client-common to the cluster's version","During rolling upgrades, keep the client at the highest cluster version","Catch YarnRuntimeException when polling status and report the raw string"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"private static final Set<JobState> KNOWN_JOB_STATES = EnumSet.of(\n    JobState.NEW, JobState.INITED, JobState.RUNNING, JobState.SUCCEEDED,\n    JobState.FAILED, JobState.KILLED, JobState.ERROR);\nif (!KNOWN_JOB_STATES.contains(jobState)) { /* raw handling */ }","typeGuard":"static boolean isMappableJobState(JobState s) {\n  return EnumSet.of(JobState.NEW, JobState.INITED, JobState.RUNNING,\n      JobState.SUCCEEDED, JobState.FAILED, JobState.KILLED,\n      JobState.ERROR).contains(s);\n}","tryCatchPattern":"try {\n  runState = TypeConverter.fromYarn(jobState);\n} catch (YarnRuntimeException e) {\n  LOG.warn(\"Unknown job state {} from cluster; treating as RUNNING\", jobState);\n  runState = JobStatus.RUNNING;\n}","preventionTips":["During rolling upgrades, run clients at the newest cluster version","Poll status through a helper that tolerates unknown states instead of raw TypeConverter"],"tags":["hadoop","mapreduce","yarn","job-state","enum-conversion","version-mismatch"],"backgroundTag":"unrecognized-enum-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}