{"record":{"id":"2125e4d9b939aca4","repo":"apache/hadoop","slug":"unrecognized-task-type","errorCode":null,"errorMessage":"Unrecognized task type: {}","messagePattern":"Unrecognized task type: (.+?)","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":122,"sourceCode":"  }\n\n  private static String fromClusterTimeStamp(long clusterTimeStamp) {\n    return Long.toString(clusterTimeStamp);\n  }\n\n  private static long toClusterTimeStamp(String identifier) {\n    return Long.parseLong(identifier);\n  }\n\n  public static org.apache.hadoop.mapreduce.TaskType fromYarn(\n      TaskType taskType) {\n    switch (taskType) {\n    case MAP:\n      return org.apache.hadoop.mapreduce.TaskType.MAP;\n    case REDUCE:\n      return org.apache.hadoop.mapreduce.TaskType.REDUCE;\n    default:\n      throw new YarnRuntimeException(\"Unrecognized task type: \" + taskType);\n    }\n  }\n\n  public static TaskType\n      toYarn(org.apache.hadoop.mapreduce.TaskType taskType) {\n    switch (taskType) {\n    case MAP:\n      return TaskType.MAP;\n    case REDUCE:\n      return TaskType.REDUCE;\n    default:\n      throw new YarnRuntimeException(\"Unrecognized task type: \" + taskType);\n    }\n  }\n\n  public static org.apache.hadoop.mapred.TaskID fromYarn(TaskId id) {\n    return new org.apache.hadoop.mapred.TaskID(fromYarn(id.getJobId()),\n      fromYarn(id.getTaskType()), id.getId());","sourceCodeStart":104,"sourceCodeEnd":140,"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#L104-L140","documentation":"TypeConverter.fromYarn(TaskType) maps the MRv2 protocol enum to the old-API enum but only handles MAP and REDUCE — the two types the MR runtime actually creates task objects for — and throws YarnRuntimeException for anything else. It is defensive: with the current MRv2 enum the default is unreachable, so hitting it means the value came from a different (newer) protocol version or a synthetic record.","triggerScenarios":"A MRv2 protocol response (task reports, completion events) carrying a TaskType constant other than MAP/REDUCE — e.g. from a newer ResourceManager/MR AppMaster than the client jar; unit tests fabricating TaskId/TaskType records.","commonSituations":"Client jars older than the cluster (down-level mapreduce-client-common); rolling upgrades where the wire protocol gained a task-type constant; test fixtures using mock protocol records with unmapped values.","solutions":["Match the hadoop-mapreduce-client-common version to the cluster (same Hadoop release on client and server)","If you control the records, filter to MAP/REDUCE before conversion","Catch YarnRuntimeException at the API boundary and degrade (skip the record, log the raw value)"],"exampleFix":"// before\norg.apache.hadoop.mapreduce.TaskType t = TypeConverter.fromYarn(task.getType());\n\n// after\nif (task.getType() == TaskType.MAP || task.getType() == TaskType.REDUCE) {\n  org.apache.hadoop.mapreduce.TaskType t = TypeConverter.fromYarn(task.getType());\n} // else skip/report unknown kind","handlingStrategy":"type-guard","validationCode":"TaskType t = yarnTask.getType();\nif (t != TaskType.MAP && t != TaskType.REDUCE) {\n  LOG.warn(\"Skipping non map/reduce task type {}\", t); continue;\n}","typeGuard":"static boolean isMappableTaskType(TaskType t) {\n  return t == TaskType.MAP || t == TaskType.REDUCE;\n}","tryCatchPattern":"try {\n  oldType = TypeConverter.fromYarn(yarnType);\n} catch (YarnRuntimeException e) {\n  LOG.warn(\"Dropping task with unmapped type {}\", yarnType);\n  continue;\n}","preventionTips":["Verify client jar version matches the cluster before parsing its reports","Filter protocol records to known-good enum values before TypeConverter calls"],"tags":["hadoop","mapreduce","yarn","task-type","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"}