{"record":{"id":"305735bc14cd2ebc","repo":"apache/hadoop","slug":"the-version-section-doesn-t-contain-the-ondiskve","errorCode":null,"errorMessage":"The <version> section doesn't contain the onDiskVersion.","messagePattern":"The <version> section doesn't contain the onDiskVersion\\.","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":1692,"sourceCode":"   * Read the version tag which starts the XML file.\n   */\n  private void readVersion() throws IOException {\n    try {\n      expectTag(\"version\", false);\n    } catch (IOException e) {\n      // Handle the case where <version> does not exist.\n      // Note: fsimage XML files which are missing <version> are also missing\n      // many other fields that oiv needs to accurately reconstruct the\n      // fsimage.\n      throw new IOException(\"No <version> section found at the top of \" +\n          \"the fsimage XML.  This XML file is too old to be processed \" +\n          \"by oiv.\", e);\n    }\n    Node version = new Node();\n    loadNodeChildren(version, \"version fields\");\n    Integer onDiskVersion = version.removeChildInt(\"onDiskVersion\");\n    if (onDiskVersion == null) {\n      throw new IOException(\"The <version> section doesn't contain \" +\n          \"the onDiskVersion.\");\n    }\n    Integer layoutVersion = version.removeChildInt(\"layoutVersion\");\n    if (layoutVersion == null) {\n      throw new IOException(\"The <version> section doesn't contain \" +\n          \"the layoutVersion.\");\n    }\n    if (layoutVersion.intValue() !=\n        NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION) {\n      throw new IOException(\"Layout version mismatch.  This oiv tool \" +\n          \"handles layout version \" +\n          NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION + \", but the \" +\n          \"XML file has <layoutVersion> \" + layoutVersion + \".  Please \" +\n          \"either re-generate the XML file with the proper layout version, \" +\n          \"or manually edit the XML file to be usable with this version \" +\n          \"of the oiv tool.\");\n    }\n    fileSummaryBld.setOndiskVersion(onDiskVersion);","sourceCodeStart":1674,"sourceCodeEnd":1710,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L1674-L1710","documentation":"The <version> section exists but contains no <onDiskVersion> child, which becomes FileSummary.onDiskVersion in the reconstructed image header. Without it the output fsimage would have no valid summary, so the tool refuses to continue.","triggerScenarios":"A <version> element whose <onDiskVersion> child was omitted, renamed, or misspelled (exact tag required), typically in hand-edited or script-generated XML.","commonSituations":"Hand-built version headers copied incompletely; renaming fields for readability; XML trimmed by a transform that dropped 'uninteresting' fields.","solutions":["Add <onDiskVersion>1</onDiskVersion> inside <version> (the value oiv itself writes)","Check exact tag spelling/case - 'onDiskVersion'","If unsure of the value, regenerate the XML with a same-version oiv and diff the <version> block","Validate the version block before reconstructing"],"exampleFix":"<!-- before -->\n<version><layoutVersion>-66</layoutVersion></version>\n<!-- after -->\n<version><onDiskVersion>1</onDiskVersion><layoutVersion>-66</layoutVersion></version>","handlingStrategy":"validation","validationCode":"# python: <version> must contain <onDiskVersion>\nimport xml.etree.ElementTree as ET\n\ndef version_block_ok(path):\n    for ev, el in ET.iterparse(path, events=('end',)):\n        if el.tag == 'version':\n            return el.find('onDiskVersion') is not None\n    return False","typeGuard":null,"tryCatchPattern":"// catch the missing-onDiskVersion failure; copy the <version> block from\n// a same-version oiv dump, delete partial output, re-run","preventionTips":["Copy the whole <version> block verbatim from a same-build dump","Treat the version block as fixed boilerplate, never hand-assemble it","Validate the block pre-flight","Regenerate the dump when the block is damaged"],"tags":["hdfs","oiv","fsimage","reversexml","version","missing-field"],"backgroundTag":"fsimage-version-field-missing","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}