{"record":{"id":"c3b5a7bbf4d12262","repo":"apache/hadoop","slug":"event-schema-string-not-parsed-since-its-null","errorCode":null,"errorMessage":"Event schema string not parsed since its null","messagePattern":"Event schema string not parsed since its null","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/jobhistory/EventReader.java","lineNumber":88,"sourceCode":"    Schema myschema = new SpecificData(Event.class.getClassLoader()).getSchema(Event.class);\n    Schema.Parser parser = new Schema.Parser();\n    String eventschema = in.readLine();\n    if (null != eventschema) {\n      try {\n        this.schema = parser.parse(eventschema);\n        this.reader = new SpecificDatumReader(schema, myschema);\n        if (EventWriter.VERSION.equals(version)) {\n          this.decoder = DecoderFactory.get().jsonDecoder(schema, in);\n        } else if (EventWriter.VERSION_BINARY.equals(version)) {\n          this.decoder = DecoderFactory.get().binaryDecoder(in, null);\n        } else {\n          throw new IOException(\"Incompatible event log version: \" + version);\n        }\n      } catch (AvroRuntimeException e) {\n        throw new IOException(e);\n      }\n    } else {\n      throw new IOException(\"Event schema string not parsed since its null\");\n    }\n  }\n  \n  /**\n   * Get the next event from the stream\n   * @return the next event\n   * @throws IOException\n   */\n  @SuppressWarnings(\"unchecked\")\n  public HistoryEvent getNextEvent() throws IOException {\n    Event wrapper;\n    try {\n      wrapper = (Event)reader.read(null, decoder);\n    } catch (EOFException e) {            // at EOF\n      return null;\n    }\n    HistoryEvent result;\n    switch (wrapper.getType()) {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/jobhistory/EventReader.java#L70-L106","documentation":"A job history file's second line carries the Avro schema EventWriter emits after the version line. If EventReader reads null for that line the stream ended prematurely, and it throws IOException(\"Event schema string not parsed since its null\"): the file is empty or truncated before the header was flushed, so no events can ever be decoded from it.","triggerScenarios":"new EventReader(in) on a 0-byte file, a file containing only the version line, or a .jhist truncated at the very start - typically a history file from a job that was killed/crashed before the writer flushed, or an HDFS file with missing blocks.","commonSituations":"History scanning tools globbing intermediatedone/ picking up in-progress or aborted files; manually copied/truncated history files; jobs killed immediately after submission leaving stub .jhist files.","solutions":["Pre-check the file: skip files of length 0 or whose first two lines cannot be read.","For finished jobs, consume files from the done/ (completed) history directory rather than the intermediate one.","Regenerate history by re-running the job if the record is required and the file is unrecoverable.","Verify HDFS file integrity (hdfs fsck) if truncation is unexpected."],"exampleFix":"// before\nEventReader reader = new EventReader(fs.open(historyPath)); // IOException on empty file\n\n// after\nFileStatus st = fs.getFileStatus(historyPath);\nif (st.getLen() == 0) {\n  LOG.warn(\"Skipping empty history file \" + historyPath);\n  continue;\n}\nEventReader reader = new EventReader(fs.open(historyPath));","handlingStrategy":"validation","validationCode":"FileStatus st = fs.getFileStatus(path);\nif (st.getLen() == 0) {\n  // empty history stub (aborted job) - skip\n}","typeGuard":null,"tryCatchPattern":"catch (IOException e) with message \"Event schema string not parsed\": treat the file as truncated/empty, skip it, and continue the scan - no retry can help.","preventionTips":["Filter zero-length files when scanning history directories.","Prefer done/ (completed jobs) over intermediatedone/ for stable files.","Ensure jobs complete or are allowed to write their history footer before archiving files."],"tags":["hadoop","mapreduce","jobhistory","truncated-file","empty-file","ioexception"],"backgroundTag":"truncated-file","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}