apache/hadoop · error · RuntimeException
unexpected event type: ${wrapper.getType()}
Error message
unexpected event type: ${wrapper.getType()} What it means
EventReader.getNextEvent maps each decoded Avro Event wrapper's EventType (JOB_SUBMITTED, TASK_FINISHED, AM_STARTED, ...) to a concrete HistoryEvent class via a switch. The default branch throws RuntimeException("unexpected event type") for a type with no mapping - reachable only when the history contains an EventType this build does not know (newer writer) or the decoded payload is garbage.
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/jobhistory/EventReader.java:170
result = new TaskAttemptStartedEvent(); break;
case SETUP_ATTEMPT_FINISHED:
result = new TaskAttemptFinishedEvent(); break;
case SETUP_ATTEMPT_FAILED:
result = new TaskAttemptUnsuccessfulCompletionEvent(); break;
case SETUP_ATTEMPT_KILLED:
result = new TaskAttemptUnsuccessfulCompletionEvent(); break;
case CLEANUP_ATTEMPT_STARTED:
result = new TaskAttemptStartedEvent(); break;
case CLEANUP_ATTEMPT_FINISHED:
result = new TaskAttemptFinishedEvent(); break;
case CLEANUP_ATTEMPT_FAILED:
result = new TaskAttemptUnsuccessfulCompletionEvent(); break;
case CLEANUP_ATTEMPT_KILLED:
result = new TaskAttemptUnsuccessfulCompletionEvent(); break;
case AM_STARTED:
result = new AMStartedEvent(); break;
default:
throw new RuntimeException("unexpected event type: " + wrapper.getType());
}
result.setDatum(wrapper.getEvent());
return result;
}
/**
* Close the Event reader
* @throws IOException
*/
@Override
public void close() throws IOException {
if (in != null) {
in.close();
}
in = null;
}
static Counters fromAvro(JhCounters counters) {View on GitHub (pinned to 2add963021)
Solutions
- Read the history with a Hadoop version equal to or newer than the one that wrote it.
- Skip the unreadable file and continue the scan (one bad file should not abort directory-level tooling).
- If you fork and add event types, add the mapping case in EventReader in the same change.
- Treat persistent occurrences as corruption: recover via HDFS replicas or re-run.
Example fix
// defensive directory scan pattern
try {
HistoryEvent e = reader.getNextEvent();
} catch (RuntimeException re) {
if (re.getMessage() != null && re.getMessage().startsWith("unexpected event type")) {
LOG.warn("History from newer Hadoop? Skipping " + path);
continue; // skip file, keep scanning
}
throw re;
} Defensive patterns
Strategy: try-catch
Try / catch
catch (RuntimeException e) from getNextEvent(): if message starts with "unexpected event type", skip the remainder of that file (likely newer-format history) and continue the scan; otherwise propagate.
Prevention
- Read history with a Hadoop version >= the writer's version.
- In forks adding event types, update EventReader's switch in the same commit.
- Isolate per-file parsing so one bad file cannot abort a batch.
When it happens
Trigger: Reading a .jhist written by a newer Hadoop build or fork that added EventType constants unknown to this reader; Avro decoding producing a corrupt type value from a damaged stream.
Common situations: Parsing history across Hadoop versions (downgrade direction); patched Hadoop with extra event types; history files damaged in storage.
Related errors
- Unknown mode: ${mode}
- MapReduce JobHistory WebApp Address does not contain a valid
- Incompatible event log version: ${version}
- Event schema string not parsed since its null
- Unable to initialize History Viewer
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/4d64e606eda39c79.
Report an issue: GitHub.