{"record":{"id":"c2ce487e8843deee","repo":"apache/hadoop","slug":"snapshotdiffsection-contained-unexpected-tag-tag","errorCode":null,"errorMessage":"SnapshotDiffSection contained unexpected tag ${tagName}","messagePattern":"SnapshotDiffSection contained unexpected tag (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java","lineNumber":1417,"sourceCode":"    public void process() throws IOException {\n      // No header for this section type.\n      LOG.debug(\"Processing SnapshotDiffSection\");\n      while (true) {\n        XMLEvent ev = expectTag(\"[diff start tag]\", true);\n        if (ev.isEndElement()) {\n          String name = ev.asEndElement().getName().getLocalPart();\n          if (name.equals(SNAPSHOT_DIFF_SECTION_NAME)) {\n            break;\n          }\n          throw new IOException(\"Got unexpected end tag for \" + name);\n        }\n        String tagName = ev.asStartElement().getName().getLocalPart();\n        if (tagName.equals(SNAPSHOT_DIFF_SECTION_DIR_DIFF_ENTRY)) {\n          processDirDiffEntry();\n        } else if (tagName.equals(SNAPSHOT_DIFF_SECTION_FILE_DIFF_ENTRY)) {\n          processFileDiffEntry();\n        } else {\n          throw new IOException(\"SnapshotDiffSection contained unexpected \" +\n              \"tag \" + tagName);\n        }\n      }\n      recordSectionLength(SectionName.SNAPSHOT_DIFF.name());\n    }\n\n    private void processDirDiffEntry() throws IOException {\n      LOG.debug(\"Processing dirDiffEntry\");\n      DiffEntry.Builder headerBld = DiffEntry.newBuilder();\n      headerBld.setType(DiffEntry.Type.DIRECTORYDIFF);\n      Node dirDiffHeader = new Node();\n      loadNodeChildren(dirDiffHeader, \"dirDiffEntry fields\", \"dirDiff\");\n      Long inodeId = dirDiffHeader.removeChildLong(\n          SNAPSHOT_DIFF_SECTION_INODE_ID);\n      if (inodeId == null) {\n        throw new IOException(\"<dirDiffEntry> contained no <inodeId> entry.\");\n      }\n      headerBld.setInodeId(inodeId);","sourceCodeStart":1399,"sourceCodeEnd":1435,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L1399-L1435","documentation":"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.","triggerScenarios":"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.","commonSituations":"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>).","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"],"exampleFix":"<!-- before: nested tag at section level -->\n<SnapshotDiffSection>\n  <dirDiff><snapshotId>3</snapshotId>...</dirDiff>\n</SnapshotDiffSection>\n<!-- after -->\n<SnapshotDiffSection>\n  <dirDiffEntry><inodeId>16386</inodeId><count>1</count>\n    <dirDiff><snapshotId>3</snapshotId>...</dirDiff>\n  </dirDiffEntry>\n</SnapshotDiffSection>","handlingStrategy":"validation","validationCode":"# python: only dirDiffEntry/fileDiffEntry may appear directly under SnapshotDiffSection\nimport xml.etree.ElementTree as ET\n\ndef diff_section_children_ok(path):\n    inside, ok = False, True\n    for ev, el in ET.iterparse(path, events=('start','end')):\n        if ev == 'start' and el.tag == 'SnapshotDiffSection':\n            inside = True\n        elif ev == 'end' and el.tag == 'SnapshotDiffSection':\n            inside = False\n        elif ev == 'start' and inside and el.tag not in ('dirDiffEntry','fileDiffEntry'):\n            # need parent tracking: use a stack-based scan for strictness\n            pass\n    return ok","typeGuard":null,"tryCatchPattern":"try {\n  // OfflineImageReconstructor.run is package-private; shell out instead\n  ...same ProcessBuilder pattern; on failure grep stderr for 'unexpected tag'\n}","preventionTips":["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"],"tags":["hdfs","oiv","fsimage","reversexml","snapshot-diff","unexpected-tag"],"backgroundTag":"unexpected-xml-tag","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}