{"record":{"id":"99093ebcdf7dcb90","repo":"apache/hadoop","slug":"failed-to-find-expected-got-ev-asstartelemen","errorCode":null,"errorMessage":"Failed to find <{expected}>; got {ev.asStartElement().getName().getLocalPart()} instead.","messagePattern":"Failed to find <(.+?)>; got (.+?) instead\\.","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":217,"sourceCode":"        throw new IOException(\"Got unexpected attribute: \" + ev);\n      case XMLEvent.CHARACTERS:\n        if (!ev.asCharacters().isWhiteSpace()) {\n          throw new IOException(\"Got unxpected characters while \" +\n              \"looking for \" + expected + \": \" +\n              ev.asCharacters().getData());\n        }\n        break;\n      case XMLEvent.END_ELEMENT:\n        if (!allowEnd) {\n          throw new IOException(\"Got unexpected end event \" +\n              \"while looking for \" + expected);\n        }\n        return ev;\n      case XMLEvent.START_ELEMENT:\n        if (!expected.startsWith(\"[\")) {\n          if (!ev.asStartElement().getName().getLocalPart().\n                equals(expected)) {\n            throw new IOException(\"Failed to find <\" + expected + \">; \" +\n                \"got \" + ev.asStartElement().getName().getLocalPart() +\n                \" instead.\");\n          }\n        }\n        return ev;\n      default:\n        // Ignore other event types like comment, etc.\n        if (LOG.isTraceEnabled()) {\n          LOG.trace(\"Skipping XMLEvent of type \" +\n              ev.getEventType() + \"(\" +  ev + \")\");\n        }\n        break;\n      }\n    }\n  }\n\n  private void expectTagEnd(String expected) throws IOException {\n    XMLEvent ev = expectTag(expected, true);","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L199-L235","documentation":"When the reconstructor expects a literal tag name (anything not starting with '['), expectTag verifies the START_ELEMENT's local part matches; a different name throws this IOException naming both the expected and the actual tag. The tool walks a fixed section order (version, NameSection, INodeSection, ...), so a wrong element at a boundary means the document's structure no longer matches the dialect this oiv version emits.","triggerScenarios":"ReverseXML where a section or child element was renamed, reordered, inserted, or removed around a section boundary; XML generated by a different Hadoop release whose section names/contents differ; splices of sections from two different dumps.","commonSituations":"Feeding a newer or older oiv's XML dump into this ReverseXML (the tool separately enforces matching <layoutVersion>); hand-retagging elements during edits.","solutions":["Regenerate the XML with the same Hadoop version you will run ReverseXML with - XML and reconstructor must share a layout version","Restore the expected tag name at the reported location; the message names both expected and actual tags","Compare your file's top-level section sequence against a freshly generated dump (xmllint --xpath 'name(/*/*[N])' img.xml)"],"exampleFix":"<!-- before: section retagged -->\n<NameSysSection><namespaceId>1</namespaceId></NameSysSection>\n\n<!-- after -->\n<NameSection><namespaceId>1</namespaceId></NameSection>","handlingStrategy":"validation","validationCode":"# Section names must match this oiv version's dialect; spot-check the sequence\nfor s in version NameSection INodeSection; do\n  xmllint --xpath \"/fsimage/$s\" fsimage.xml > /dev/null 2>&1 \\\n    || { echo \"missing or renamed section <$s>\"; exit 1; };\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate and reconstruct XML with the same Hadoop build","Do not rename or reorder top-level sections when editing","After transforms, compare the top-level element list against a fresh dump"],"tags":["hdfs","reversexml","xml-tag-mismatch","fsimage"],"backgroundTag":"xml-tag-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}