{"record":{"id":"48dc742864ffa2a6","repo":"apache/hadoop","slug":"got-unexpected-attribute-ev","errorCode":null,"errorMessage":"Got unexpected attribute: {ev}","messagePattern":"Got unexpected attribute: (.+?)","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":199,"sourceCode":"   *                     unless this string is enclosed in braces.\n   * @param allowEnd     If true, we will also end events.\n   *                     If false, end events cause an exception.\n   *\n   * @return             The next tag start or end event.\n   */\n  private XMLEvent expectTag(String expected, boolean allowEnd)\n      throws IOException {\n    XMLEvent ev = null;\n    while (true) {\n      try {\n        ev = events.nextEvent();\n      } catch (XMLStreamException e) {\n        throw new IOException(\"Expecting \" + expected +\n            \", but got XMLStreamException\", e);\n      }\n      switch (ev.getEventType()) {\n      case XMLEvent.ATTRIBUTE:\n        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 + \">; \" +","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L181-L217","documentation":"expectTag scans for the next start/end element and throws on any XMLEvent.ATTRIBUTE. The XML produced by oiv's XML processor uses plain nested elements with text values and never attributes, so an attribute proves the input was rewritten by another tool (or hand-authored against a different schema) and cannot be mapped onto the fsimage schema by this reconstructor.","triggerScenarios":"ReverseXML on XML that a pretty-printer, XSLT step, or data tool rewrote by hoisting child text into attributes (e.g. <inode id=\"16386\"> instead of <inode><id>16386</id>), or hand-authored files modeled on another Hadoop tool's dialect.","commonSituations":"ETL/XSLT pipelines between the XML dump and reconstruction; editors that 'normalize' markup; examples copied from tools that legitimately use attributes.","solutions":["Convert every attribute back to a child element with the attribute's name and its value as text","Regenerate the XML directly with `hdfs oiv -p XML -i <fsimage> -o img.xml` and redo the edit structurally","If a transform step is unavoidable, assert its output is attribute-free: xmllint --xpath '//*[attribute::*]' img.xml must return nothing"],"exampleFix":"<!-- before -->\n<inode id=\"16386\" type=\"FILE\"></inode>\n\n<!-- after -->\n<inode><id>16386</id><type>FILE</type></inode>","handlingStrategy":"validation","validationCode":"# oiv XML must contain zero attributes\nn=$(xmllint --xpath 'count(//*[attribute::*])' fsimage.xml 2>/dev/null)\n[ \"$n\" = \"0\" ] || { echo \"$n attribute(s) present - convert them to child elements\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never run XSLT/pretty-printers over oiv XML between dump and ReverseXML","Structurally diff regenerated vs edited XML (tree compare), not textual diff","Model values as child elements with text, never as attributes"],"tags":["hdfs","reversexml","xml-attributes","fsimage"],"backgroundTag":"unexpected-xml-attribute","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}