{"record":{"id":"2ad02c2abbacb234","repo":"apache/hadoop","slug":"unrecognized-application-state","errorCode":null,"errorMessage":"Unrecognized application state: {}","messagePattern":"Unrecognized application 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":483,"sourceCode":"    case NEW:\n    case NEW_SAVING:\n    case SUBMITTED:\n    case ACCEPTED:\n      return State.PREP;\n    case RUNNING:\n      return State.RUNNING;\n    case FINISHED:\n      if (finalApplicationStatus == FinalApplicationStatus.SUCCEEDED) {\n        return State.SUCCEEDED;\n      } else if (finalApplicationStatus == FinalApplicationStatus.KILLED) {\n        return State.KILLED;\n      }\n    case FAILED:\n      return State.FAILED;\n    case KILLED:\n      return State.KILLED;\n    }\n    throw new YarnRuntimeException(\"Unrecognized application state: \" + yarnApplicationState);\n  }\n\n  private static final String TT_NAME_PREFIX = \"tracker_\";\n  public static TaskTrackerInfo fromYarn(NodeReport node) {\n    TaskTrackerInfo taskTracker =\n      new TaskTrackerInfo(TT_NAME_PREFIX + node.getNodeId().toString());\n    return taskTracker;\n  }\n\n  public static TaskTrackerInfo[] fromYarnNodes(List<NodeReport> nodes) {\n    List<TaskTrackerInfo> taskTrackers = new ArrayList<TaskTrackerInfo>();\n    for (NodeReport node : nodes) {\n      taskTrackers.add(fromYarn(node));\n    }\n    return taskTrackers.toArray(new TaskTrackerInfo[nodes.size()]);\n  }\n\n  public static JobStatus fromYarn(ApplicationReport application,","sourceCodeStart":465,"sourceCodeEnd":501,"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#L465-L501","documentation":"TypeConverter.fromYarn(YarnApplicationState, FinalApplicationStatus) maps every current YarnApplicationState: NEW/NEW_SAVING/SUBMITTED/ACCEPTED→PREP, RUNNING→RUNNING, KILLED→KILLED, FAILED→FAILED, and FINISHED→SUCCEEDED/KILLED with a deliberate fall-through of FINISHED-with-other-final-status (e.g. FAILED/UNDEFINED) into State.FAILED. The trailing throw is therefore unreachable for this build's enum and fires only for a state constant the jar doesn't know (or a mocked state in tests).","triggerScenarios":"An application report from a newer ResourceManager carrying a YarnApplicationState constant absent from this client build; test doubles returning custom YarnApplicationState values.","commonSituations":"Old client jars polling a newer YARN cluster (rolling upgrades); tools that deserialize reports across Hadoop versions; unit tests using mockito to fabricate reports.","solutions":["Upgrade hadoop-mapreduce-client-common (and yarn-client) to the cluster's version or newer","Catch YarnRuntimeException in status-polling loops and fall back to the raw state name","Guard with EnumSet-based checks when consuming reports from mixed-version clusters"],"exampleFix":"// before\nState s = TypeConverter.fromYarn(report.getYarnApplicationState(), report.getFinalApplicationStatus());\n\n// after\ntry {\n  State s = TypeConverter.fromYarn(report.getYarnApplicationState(), report.getFinalApplicationStatus());\n} catch (YarnRuntimeException e) {\n  LOG.warn(\"Unknown app state {} from cluster; treating as RUNNING\", report.getYarnApplicationState());\n}","handlingStrategy":"try-catch","validationCode":"private static final Set<YarnApplicationState> KNOWN = EnumSet.of(\n    YarnApplicationState.NEW, YarnApplicationState.NEW_SAVING,\n    YarnApplicationState.SUBMITTED, YarnApplicationState.ACCEPTED,\n    YarnApplicationState.RUNNING, YarnApplicationState.FINISHED,\n    YarnApplicationState.FAILED, YarnApplicationState.KILLED);\nif (!KNOWN.contains(appReport.getYarnApplicationState())) { /* degrade */ }","typeGuard":"static boolean isMappableAppState(YarnApplicationState s) {\n  return EnumSet.of(YarnApplicationState.NEW, YarnApplicationState.NEW_SAVING,\n      YarnApplicationState.SUBMITTED, YarnApplicationState.ACCEPTED,\n      YarnApplicationState.RUNNING, YarnApplicationState.FINISHED,\n      YarnApplicationState.FAILED, YarnApplicationState.KILLED).contains(s);\n}","tryCatchPattern":"try {\n  jobState = TypeConverter.fromYarn(appReport.getYarnApplicationState(),\n      appReport.getFinalApplicationStatus());\n} catch (YarnRuntimeException e) {\n  LOG.warn(\"Unknown app state {}; assuming still running\",\n      appReport.getYarnApplicationState());\n  jobState = JobStatus.RUNNING;\n}","preventionTips":["Wrap status polling in a tolerant helper when talking to mixed-version clusters","Remember FINISHED with a non-SUCCEEDED/KILLED final status maps to FAILED, not to an error"],"tags":["hadoop","mapreduce","yarn","application-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"}