{"record":{"id":"fd317fabad1a70b9","repo":"apache/hadoop","slug":"the-version-section-doesn-t-contain-the-layoutve","errorCode":null,"errorMessage":"The <version> section doesn't contain the layoutVersion.","messagePattern":"The <version> section doesn't contain the layoutVersion\\.","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":1697,"sourceCode":"    } 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);\n    fileSummaryBld.setLayoutVersion(layoutVersion);\n    if (LOG.isDebugEnabled()) {\n      LOG.debug(\"Loaded <version> with onDiskVersion=\" + onDiskVersion +\n          \", layoutVersion=\" + layoutVersion + \".\");\n    }","sourceCodeStart":1679,"sourceCodeEnd":1715,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L1679-L1715","documentation":"The <version> section contains no <layoutVersion> child, which must equal the NameNode layout version the reconstructed image claims and is written into FileSummary.layoutVersion. Its absence makes the version block incomplete and reconstruction aborts immediately after the onDiskVersion check.","triggerScenarios":"A <version> element with <layoutVersion> omitted, renamed, or nested at the wrong level; hand-authored headers where only onDiskVersion was filled in.","commonSituations":"Incomplete hand-built or template-generated version blocks; field renaming during cleanup; XML from tooling that predates the field.","solutions":["Add <layoutVersion>N</layoutVersion> inside <version>, where N must equal this oiv's NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION (a negative number, e.g. -66)","Copy the exact <version> block from an XML dump produced by the same Hadoop build you reconstruct with","Validate the version block with a pre-check script","Regenerate the XML from the original binary fsimage"],"exampleFix":"<!-- before -->\n<version><onDiskVersion>1</onDiskVersion></version>\n<!-- after -->\n<version><onDiskVersion>1</onDiskVersion><layoutVersion>-66</layoutVersion></version>","handlingStrategy":"validation","validationCode":"# python: <version> must contain <layoutVersion>\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('layoutVersion') is not None\n    return False","typeGuard":null,"tryCatchPattern":"// catch the missing-layoutVersion failure; restore the exact negative\n// value this oiv build expects (see its NameNodeLayoutVersion), re-run","preventionTips":["Never strip <layoutVersion> when trimming dumps","Keep <onDiskVersion> and <layoutVersion> together in the block","Validate the version block pre-flight","Regenerate the dump with a same-version oiv"],"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-22T20:17:22.307Z"}