{"record":{"id":"739e34bc5df331f7","repo":"apache/hadoop","slug":"unrecognized-task-state","errorCode":null,"errorMessage":"Unrecognized task state: {}","messagePattern":"Unrecognized task 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":421,"sourceCode":"    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);\n  }\n\n  public static TaskReport fromYarn(org.apache.hadoop.mapreduce.v2.api.records.TaskReport report) {\n    String[] diagnostics = null;\n    if (report.getDiagnosticsList() != null) {\n      diagnostics = new String[report.getDiagnosticsCount()];\n      int i = 0;\n      for (String cs : report.getDiagnosticsList()) {\n        diagnostics[i++] = cs.toString();\n      }\n    } else {\n      diagnostics = new String[0];\n    }\n\n    TaskReport rep = new TaskReport(fromYarn(report.getTaskId()),\n        report.getProgress(), report.getTaskState().toString(),\n      diagnostics, fromYarn(report.getTaskState()), report.getStartTime(), report.getFinishTime(),\n      fromYarn(report.getCounters()));","sourceCodeStart":403,"sourceCodeEnd":439,"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#L403-L439","documentation":"TypeConverter.fromYarn(TaskState) converts MRv2 task states into the classic TIPStatus (NEW/SCHEDULED→PENDING, RUNNING, KILLED, SUCCEEDED→COMPLETE, FAILED→FAILED) and throws YarnRuntimeException for any other constant. Like the sibling converters, all current TaskState values are covered; an unknown one means the value crossed a version boundary this jar cannot handle.","triggerScenarios":"A task report whose TaskState is outside the handled set — from a newer server, a different Hadoop fork, or a synthetic record in tests.","commonSituations":"Version mismatch between client and cluster during/after upgrades; job-history replay tools reading newer history files; vendor distributions with extended states.","solutions":["Match client jar version to the producing server","Treat unknown states as non-terminal (skip the report) instead of failing the caller","Catch YarnRuntimeException around report conversion loops"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"private static final Set<TaskState> KNOWN_TASK_STATES = EnumSet.range(\n    TaskState.NEW, TaskState.SUCCEEDED); // adjust to your build's enum\nif (!KNOWN_TASK_STATES.contains(taskState)) { /* skip report */ }","typeGuard":"static boolean isMappableTaskState(TaskState s) {\n  return s == TaskState.NEW || s == TaskState.SCHEDULED || s == TaskState.RUNNING\n      || s == TaskState.SUCCEEDED || s == TaskState.FAILED || s == TaskState.KILLED;\n}","tryCatchPattern":"try {\n  tipStatus = TypeConverter.fromYarn(taskState);\n} catch (YarnRuntimeException e) {\n  LOG.warn(\"Unknown task state {}; treating as PENDING\", taskState);\n  tipStatus = org.apache.hadoop.mapred.TIPStatus.PENDING;\n}","preventionTips":["Skip reports with unrecognized states rather than failing status aggregation","Version-lock history-replay tools to the history format they read"],"tags":["hadoop","mapreduce","yarn","task-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"}