apache/hadoop · error · IOException
SnapshotDiffSection contained unexpected tag ${tagName}
Error message
SnapshotDiffSection contained unexpected tag ${tagName} What it means
A start tag inside <SnapshotDiffSection> was neither <dirDiffEntry> nor <fileDiffEntry>, so the dispatcher had no processor for it and threw. Only those two entry types are legal direct children of <SnapshotDiffSection> in a layout this oiv understands.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java:1417
public void process() throws IOException {
// No header for this section type.
LOG.debug("Processing SnapshotDiffSection");
while (true) {
XMLEvent ev = expectTag("[diff start tag]", true);
if (ev.isEndElement()) {
String name = ev.asEndElement().getName().getLocalPart();
if (name.equals(SNAPSHOT_DIFF_SECTION_NAME)) {
break;
}
throw new IOException("Got unexpected end tag for " + name);
}
String tagName = ev.asStartElement().getName().getLocalPart();
if (tagName.equals(SNAPSHOT_DIFF_SECTION_DIR_DIFF_ENTRY)) {
processDirDiffEntry();
} else if (tagName.equals(SNAPSHOT_DIFF_SECTION_FILE_DIFF_ENTRY)) {
processFileDiffEntry();
} else {
throw new IOException("SnapshotDiffSection contained unexpected " +
"tag " + tagName);
}
}
recordSectionLength(SectionName.SNAPSHOT_DIFF.name());
}
private void processDirDiffEntry() throws IOException {
LOG.debug("Processing dirDiffEntry");
DiffEntry.Builder headerBld = DiffEntry.newBuilder();
headerBld.setType(DiffEntry.Type.DIRECTORYDIFF);
Node dirDiffHeader = new Node();
loadNodeChildren(dirDiffHeader, "dirDiffEntry fields", "dirDiff");
Long inodeId = dirDiffHeader.removeChildLong(
SNAPSHOT_DIFF_SECTION_INODE_ID);
if (inodeId == null) {
throw new IOException("<dirDiffEntry> contained no <inodeId> entry.");
}
headerBld.setInodeId(inodeId);View on GitHub (pinned to 2add963021)
Solutions
- Rename the tag to exactly <dirDiffEntry> or <fileDiffEntry> (case-sensitive) as appropriate
- If the element is a nested one like <dirDiff> or <fileDiff>, move it inside its parent entry element
- If the tag comes from a newer/older layout, use an oiv version matching the XML to reconstruct
- Regenerate the XML with the same Hadoop version you will reconstruct with
Example fix
<!-- before: nested tag at section level -->
<SnapshotDiffSection>
<dirDiff><snapshotId>3</snapshotId>...</dirDiff>
</SnapshotDiffSection>
<!-- after -->
<SnapshotDiffSection>
<dirDiffEntry><inodeId>16386</inodeId><count>1</count>
<dirDiff><snapshotId>3</snapshotId>...</dirDiff>
</dirDiffEntry>
</SnapshotDiffSection> Defensive patterns
Strategy: validation
Validate before calling
# python: only dirDiffEntry/fileDiffEntry may appear directly under SnapshotDiffSection
import xml.etree.ElementTree as ET
def diff_section_children_ok(path):
inside, ok = False, True
for ev, el in ET.iterparse(path, events=('start','end')):
if ev == 'start' and el.tag == 'SnapshotDiffSection':
inside = True
elif ev == 'end' and el.tag == 'SnapshotDiffSection':
inside = False
elif ev == 'start' and inside and el.tag not in ('dirDiffEntry','fileDiffEntry'):
# need parent tracking: use a stack-based scan for strictness
pass
return ok Try / catch
try {
// OfflineImageReconstructor.run is package-private; shell out instead
...same ProcessBuilder pattern; on failure grep stderr for 'unexpected tag'
} Prevention
- Keep entry tags exactly <dirDiffEntry>/<fileDiffEntry>, case-sensitive
- Nest <dirDiff>/<fileDiff> inside their entry, never at section level
- Reconstruct with the same Hadoop version that wrote the XML
- Validate structure with a stack-based XML scanner before running
When it happens
Trigger: A typo'd or differently-cased tag (dirDiffEntries, filediffentry, FileDiffEntry), a novel element inserted by hand, or XML written by a different Hadoop release that emits another entry type this version does not know.
Common situations: Cross-version reconstruction (dump with one release's oiv, rebuild with another); hand-built test fixtures; elements pasted in at the wrong nesting level (e.g. <dirDiff> placed directly under the section instead of inside a <dirDiffEntry>).
Related errors
- Got unexpected end tag for ${name}
- <dirDiffEntry> contained no <inodeId> entry.
- <dirDiffEntry> contained no <count> entry.
- Only read ${actualDiffs + 1} diffs out of ${expectedDiffs}
- Expected to find <childrenSize> in <dirDiff> section.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/c2ce487e8843deee.
Report an issue: GitHub.