{"record":{"id":"2a5629f1b52f833c","repo":"apache/hadoop","slug":"got-unexpected-end-tag-for-name","errorCode":null,"errorMessage":"Got unexpected end tag for ${name}","messagePattern":"Got unexpected end tag for (.+?)","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":1409,"sourceCode":"      recordSectionLength(SectionName.SNAPSHOT.name());\n    }\n  }\n\n  private class SnapshotDiffSectionProcessor implements SectionProcessor {\n    static final String NAME = \"SnapshotDiffSection\";\n\n    @Override\n    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);","sourceCodeStart":1391,"sourceCodeEnd":1427,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L1391-L1427","documentation":"While scanning <SnapshotDiffSection>, ReverseXML read an end-element event whose name was not the section-closing </SnapshotDiffSection>. The section's main loop only accepts <dirDiffEntry>/<fileDiffEntry> start tags and the final section end tag (expectTag with allowEnd=true); any other closing tag aborts the tool. The offending tag name is included in the message.","triggerScenarios":"An extra, duplicated, or orphaned closing tag inside <SnapshotDiffSection> - e.g. a leftover </dirDiff> after a hand-deleted block, or an element removed but its close tag kept; also mis-nested elements from sed/regex surgery on the XML.","commonSituations":"Scripted edits that delete diff entries by line range; XML re-serialized by tools that re-order or duplicate close tags; merging sections from two dumps.","solutions":["Run xmllint --noout dump.xml to verify well-formedness, then locate the tag named in the message and fix its open/close balance","If an entry was deleted, make sure both its start and end tags went with it","Re-extract the section from the original dump instead of hand-patching","Regenerate the whole XML with a same-version oiv"],"exampleFix":"<!-- before: orphaned close tag after a deleted entry -->\n<dirDiffEntry>...</dirDiffEntry>\n</dirDiff>\n</SnapshotDiffSection>\n<!-- after -->\n<dirDiffEntry>...</dirDiffEntry>\n</SnapshotDiffSection>","handlingStrategy":"validation","validationCode":"# well-formedness first, then tag-balance inside SnapshotDiffSection\n# xmllint --noout dump.xml\nimport xml.etree.ElementTree as ET\nET.parse('dump.xml')  # raises ParseError on unbalanced tags","typeGuard":null,"tryCatchPattern":"# catch the CLI failure and surface the named tag\nif subprocess.call(['hdfs','oiv','-processor','ReverseXML','-i','dump.xml','-o','out.img']) != 0:\n    # message names the unexpected end tag; grep the XML for it\n    ...","preventionTips":["Run xmllint --noout on every edited dump before reconstruction","Delete whole elements (start+end tags), never line ranges","Prefer regenerating sections over hand-patching them","Keep the original dump so edits are always reversible"],"tags":["hdfs","oiv","fsimage","reversexml","snapshot-diff","malformed-xml"],"backgroundTag":"unexpected-xml-end-tag","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}