apache/hadoop · error · IOException
Got unexpected tag end event for {} while looking for sectio
Error message
Got unexpected tag end event for {} while looking for section header tag. What it means
While looking for the next section header inside <fsimage>, the ReverseXML StAX reader received an END_ELEMENT whose name is not fsimage. In valid OIV XML the only end tag that can legally appear at this position is </fsimage> itself, so an unexpected closing tag means the top-level element nesting is broken — typically a stray or duplicated closing tag left behind by editing or splicing.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java:1775
// Write the HDFSIMG1 magic number which begins the fsimage file.
out.write(FSImageUtil.MAGIC_HEADER);
// Write a series of fsimage sections.
sectionStartOffset = FSImageUtil.MAGIC_HEADER.length;
final HashSet<String> unprocessedSections =
new HashSet<>(sections.keySet());
while (!unprocessedSections.isEmpty()) {
XMLEvent ev = expectTag("[section header]", true);
if (ev.getEventType() == XMLStreamConstants.END_ELEMENT) {
if (ev.asEndElement().getName().getLocalPart().equals("fsimage")) {
if(unprocessedSections.size() == 1 && unprocessedSections.contains
(SnapshotDiffSectionProcessor.NAME)){
break;
}
throw new IOException("FSImage XML ended prematurely, without " +
"including section(s) " + StringUtils.join(", ",
unprocessedSections));
}
throw new IOException("Got unexpected tag end event for " +
ev.asEndElement().getName().getLocalPart() + " while looking " +
"for section header tag.");
} else if (ev.getEventType() != XMLStreamConstants.START_ELEMENT) {
throw new IOException("Expected section header START_ELEMENT; " +
"got event of type " + ev.getEventType());
}
String sectionName = ev.asStartElement().getName().getLocalPart();
if (!unprocessedSections.contains(sectionName)) {
throw new IOException("Unknown or duplicate section found for " +
sectionName);
}
SectionProcessor sectionProcessor = sections.get(sectionName);
if (sectionProcessor == null) {
throw new IOException("Unknown FSImage section " + sectionName +
". Valid section names are [" +
StringUtils.join(", ", sections.keySet()) + "]");
}
unprocessedSections.remove(sectionName);View on GitHub (pinned to 2add963021)
Solutions
- Regenerate the XML from the original fsimage via `hdfs oiv -p XML`
- Run `xmllint --noout image.xml` — an unmatched closing tag is a well-formedness error and xmllint names the tag and line number
- Diff the edited file against pristine OIV output to find where the nesting broke
Example fix
# before: reconstruct edited XML hdfs oiv -p ReverseXML -i edited.xml -o out # IOException: Got unexpected tag end event for INODE while looking for section header tag. # after: locate the mismatch before reconstructing xmllint --noout edited.xml # edited.xml:12: parser error : Opening and ending tag mismatch: INODE line 5 and INODE
Defensive patterns
Strategy: validation
Validate before calling
# an unmatched closing tag is a well-formedness error; xmllint names tag and line
xmllint --noout fsimage.xml
# or without xmllint:
python3 -c "import xml.etree.ElementTree as ET; ET.parse('fsimage.xml')" Prevention
- Always validate OIV XML with xmllint --noout before feeding it to ReverseXML
- Prefer regenerating the XML from the fsimage over merging or hand-editing section blocks
- When scripting transformations, parse and re-serialize with a real XML library instead of sed/awk
When it happens
Trigger: A top-level stray closing tag (e.g. </INODE> without its opening section), duplicated close tags from copy-paste, a section element opened inside another section and closed outside it, or a SectionProcessor stopping before consuming its own end tag on malformed inner content.
Common situations: Hand-merging two OIV XML files; scripts that cut and paste section blocks; XML from a homegrown generator that emits unbalanced tags.
Related errors
- FSImage XML ended prematurely, without including section(s)
- Expected section header START_ELEMENT; got event of type {}
- Unknown or duplicate section found for {}
- Unrecognized FSImage
- no entry found for {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/2449599a1d2cfd01.
Report an issue: GitHub.