{"record":{"id":"e337722166bf18a2","repo":"apache/hadoop","slug":"failed-to-find-numinodes-in-inodesection","errorCode":null,"errorMessage":"Failed to find <numInodes> in INodeSection.","messagePattern":"Failed to find <numInodes> in INodeSection\\.","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":586,"sourceCode":"    }\n  }\n\n  private class INodeSectionProcessor implements SectionProcessor {\n    static final String NAME = \"INodeSection\";\n\n    @Override\n    public void process() throws IOException {\n      Node headerNode = new Node();\n      loadNodeChildren(headerNode, \"INodeSection fields\", \"inode\");\n      INodeSection.Builder b =  INodeSection.newBuilder();\n      Long lval = headerNode.removeChildLong(INODE_SECTION_LAST_INODE_ID);\n      if (lval != null)  {\n        b.setLastInodeId(lval);\n      }\n      Integer expectedNumINodes =\n          headerNode.removeChildInt(INODE_SECTION_NUM_INODES);\n      if (expectedNumINodes == null) {\n        throw new IOException(\"Failed to find <numInodes> in INodeSection.\");\n      }\n      b.setNumInodes(expectedNumINodes);\n      INodeSection s = b.build();\n      s.writeDelimitedTo(out);\n      headerNode.verifyNoRemainingKeys(\"INodeSection\");\n      int actualNumINodes = 0;\n      while (actualNumINodes < expectedNumINodes) {\n        try {\n          expectTag(INODE_SECTION_INODE, false);\n        } catch (IOException e) {\n          throw new IOException(\"Only found \" + actualNumINodes +\n              \" <inode> entries out of \" + expectedNumINodes, e);\n        }\n        actualNumINodes++;\n        Node inode = new Node();\n        loadNodeChildren(inode, \"INode fields\");\n        INodeSection.INode.Builder inodeBld = processINodeXml(inode);\n        inodeBld.build().writeDelimitedTo(out);","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L568-L604","documentation":"INodeSectionProcessor reads the section header into a Node and requires INODE_SECTION_NUM_INODES (<numInodes>); the value is stored in the protobuf header and drives the loop that consumes exactly that many <inode> entries. Missing it means the header was edited down, the element was renamed, or the XML comes from a dialect that does not carry it.","triggerScenarios":"ReverseXML after <numInodes> was deleted or renamed inside <INodeSection>, or two INodeSections merged without combining their headers.","commonSituations":"Namespace-pruning attempts by editing XML; version-skewed dumps; copy-paste of section bodies without headers.","solutions":["Set <numInodes> to the exact number of <inode> elements present in the section","Regenerate the dump and prune with a DOM/XPath tool that recomputes counts","Validate the pair before running: xmllint --xpath 'count(//inode)' img.xml must equal the <numInodes> text"],"exampleFix":"<!-- before -->\n<INodeSection><lastInodeId>16401</lastInodeId></INodeSection>\n\n<!-- after -->\n<INodeSection><lastInodeId>16401</lastInodeId><numInodes>1</numInodes><inode>...</inode></INodeSection>","handlingStrategy":"validation","validationCode":"declared=$(xmllint --xpath 'string(//INodeSection/numInodes)' fsimage.xml 2>/dev/null)\nactual=$(xmllint --xpath 'count(//inode)' fsimage.xml)\ncase \"$declared\" in ''|*[!0-9]*) echo '<numInodes> missing or non-numeric'; exit 1;; esac\n[ \"$declared\" = \"$actual\" ] || { echo \"numInodes=$declared vs $actual entries\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat <numInodes> as derived data: recompute it whenever entries change","Automate section merges with DOM tools that rebuild headers","Pair every section with its header when copy-pasting"],"tags":["hdfs","reversexml","fsimage","required-field","inodesection"],"backgroundTag":"required-field-missing","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}