{"record":{"id":"3b0c48a83794f946","repo":"apache/hadoop","slug":"expected-a-data-tag","errorCode":null,"errorMessage":"expected a <DATA> tag","messagePattern":"expected a <DATA> tag","errorType":"validation","errorClass":"InvalidXmlException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/OfflineEditsXmlLoader.java","lineNumber":164,"sourceCode":"        throw new InvalidXmlException(\"you must put \" +\n            \"<EDITS_VERSION> at the top of the XML file! \" +\n            \"Got tag \" + name + \" instead\");\n      }\n      break;\n    case EXPECT_RECORD:\n      if (!name.equals(\"RECORD\")) {\n        throw new InvalidXmlException(\"expected a <RECORD> tag\");\n      }\n      state = ParseState.EXPECT_OPCODE;\n      break;\n    case EXPECT_OPCODE:\n      if (!name.equals(\"OPCODE\")) {\n        throw new InvalidXmlException(\"expected an <OPCODE> tag\");\n      }\n      break;\n    case EXPECT_DATA:\n      if (!name.equals(\"DATA\")) {\n        throw new InvalidXmlException(\"expected a <DATA> tag\");\n      }\n      stanza = new Stanza();\n      state = ParseState.HANDLE_DATA;\n      break;\n    case HANDLE_DATA:\n      Stanza parent = stanza;\n      Stanza child = new Stanza();\n      stanzaStack.push(parent);\n      stanza = child;\n      parent.addChild(name, child);\n      break;\n    case EXPECT_END:\n      throw new InvalidXmlException(\"not expecting anything after </EDITS>\");\n    }\n  }\n  \n  @Override\n  public void endElement (String uri, String name, String qName) {","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineEditsViewer/OfflineEditsXmlLoader.java#L146-L182","documentation":"After <OPCODE> closes, the loader is in ParseState.EXPECT_DATA and the next element must be <DATA>, which opens the stanza tree holding the operation's fields. Any other element there throws InvalidXmlException('expected a <DATA> tag'), and the parse aborts before the record can be converted.","triggerScenarios":"A <RECORD> containing only an OPCODE (DATA removed), a duplicated OPCODE element instead of DATA, or an arbitrary child element inserted between OPCODE and DATA.","commonSituations":"Fixtures trimmed down to minimal records that accidentally dropped DATA; record merging that concatenated two OPCODEs; template-based generators emitting the wrong child name.","solutions":["Ensure every <RECORD> has exactly the pair <OPCODE> then <DATA> (DATA may hold nested stanza children).","For opcodes with no fields, keep an empty <DATA></DATA> element as emitted by oev itself.","Regenerate or copy the record from an authentic XML dump of the same opcode."],"exampleFix":"<!-- before -->\n<RECORD><OPCODE>9</OPCODE><OPCODE>9</OPCODE></RECORD>\n\n<!-- after -->\n<RECORD><OPCODE>9</OPCODE><DATA><TXID>1</TXID></DATA></RECORD>","handlingStrategy":"validation","validationCode":"// Inside each RECORD, second child must be DATA\ntry (XMLStreamReader r = XMLInputFactory.newFactory()\n        .createXMLStreamReader(new FileInputStream(file))) {\n  while (r.hasNext()) {\n    int ev = r.next();\n    if (ev == XMLStreamConstants.START_ELEMENT\n        && \"RECORD\".equals(r.getLocalName())) {\n      r.nextTag();                          // OPCODE\n      r.nextTag();                          // must be DATA\n      if (!\"DATA\".equals(r.getLocalName())) {\n        throw new IOException(\"Expected <DATA> after <OPCODE>, found <\"\n            + r.getLocalName() + \">\");\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  loader.loadEdits();\n} catch (InvalidXmlException e) {\n  if (e.getMessage().contains(\"<DATA>\")) {\n    throw new IOException(\"Each <RECORD> needs an <OPCODE> followed by a \"\n        + \"<DATA> block (empty allowed). \" + e.getMessage(), e);\n  }\n  throw e;\n}","preventionTips":["Keep every RECORD as the strict pair OPCODE + DATA, even when DATA is empty.","Validate generated XML with a structural walker before feeding it to oev."],"tags":["hadoop","hdfs","offline-edits-viewer","xml","parsing"],"backgroundTag":"malformed-xml-document","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}