{"record":{"id":"a096f67869e594ea","repo":"apache/hadoop","slug":"only-read-diffs-out-of","errorCode":null,"errorMessage":"Only read {} diffs out of {}","messagePattern":"Only read (.+?) diffs out of (.+?)","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":1555,"sourceCode":"      Long inodeId = fileDiffHeader.removeChildLong(\n          SNAPSHOT_DIFF_SECTION_INODE_ID);\n      if (inodeId == null) {\n        throw new IOException(\"<fileDiffEntry> contained no <inodeid> entry.\");\n      }\n      headerBld.setInodeId(inodeId);\n      Integer expectedDiffs = fileDiffHeader.removeChildInt(\n          SNAPSHOT_DIFF_SECTION_COUNT);\n      if (expectedDiffs == null) {\n        throw new IOException(\"<fileDiffEntry> contained no <count> entry.\");\n      }\n      headerBld.setNumOfDiff(expectedDiffs);\n      fileDiffHeader.verifyNoRemainingKeys(\"fileDiffEntry\");\n      headerBld.build().writeDelimitedTo(out);\n      for (int actualDiffs = 0; actualDiffs < expectedDiffs; actualDiffs++) {\n        try {\n          expectTag(SNAPSHOT_DIFF_SECTION_FILE_DIFF, false);\n        } catch (IOException e) {\n          throw new IOException(\"Only read \" + (actualDiffs + 1) +\n              \" diffs out of \" + expectedDiffs, e);\n        }\n        Node fileDiff = new Node();\n        loadNodeChildren(fileDiff, \"fileDiff fields\");\n        FsImageProto.SnapshotDiffSection.FileDiff.Builder bld =\n            FsImageProto.SnapshotDiffSection.FileDiff.newBuilder();\n        Integer snapshotId = fileDiff.removeChildInt(\n            SNAPSHOT_DIFF_SECTION_SNAPSHOT_ID);\n        if (snapshotId != null) {\n          bld.setSnapshotId(snapshotId);\n        }\n        Long size = fileDiff.removeChildLong(\n            SNAPSHOT_DIFF_SECTION_SIZE);\n        if (size != null) {\n          bld.setFileSize(size);\n        }\n        String name = fileDiff.removeChildStr(SECTION_NAME);\n        if (name != null) {","sourceCodeStart":1537,"sourceCodeEnd":1573,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L1537-L1573","documentation":"While reading the <count>-declared <fileDiff> children of a <fileDiffEntry>, expectTag(\"fileDiff\") failed before the declared count was consumed; the cause is re-wrapped with this message. Like the dir-diff variant, the message prints actualDiffs+1 - one more than the diffs actually read - so interpret the number accordingly.","triggerScenarios":"<count> greater than the number of <fileDiff> elements in the entry, or a malformed <fileDiff> that makes the reader hit an unexpected tag/end event mid-loop.","commonSituations":"Hand-edits deleting file diffs without updating <count>; scripts appending diffs without recounting; truncated entries from sed/awk surgery on huge XML.","solutions":["Read the chained cause for the underlying tag mismatch","Set <count> to the actual number of <fileDiff> elements in that <fileDiffEntry>","Restore any truncated or deleted <fileDiff> blocks","Stream-validate count vs entries for every fileDiffEntry before reconstructing"],"exampleFix":"<!-- before: count says 2, one diff present -->\n<fileDiffEntry><inodeId>16390</inodeId><count>2</count>\n  <fileDiff>...</fileDiff>\n</fileDiffEntry>\n<!-- after -->\n<fileDiffEntry><inodeId>16390</inodeId><count>1</count>\n  <fileDiff>...</fileDiff>\n</fileDiffEntry>","handlingStrategy":"validation","validationCode":"# python: <count> must equal number of <fileDiff> children per fileDiffEntry\nimport xml.etree.ElementTree as ET\n\ndef validate(path):\n    for ev, el in ET.iterparse(path, events=('end',)):\n        if el.tag == 'fileDiffEntry':\n            c = el.find('count')\n            if c is None or int(c.text) != len(el.findall('fileDiff')):\n                return False\n    return True","typeGuard":null,"tryCatchPattern":"# on 'Only read N diffs out of M' read the chained cause in stderr,\n# fix count or restore diffs, remove partial output, re-run","preventionTips":["Message over-reports by one (actualDiffs+1 quirk) - plan accordingly","Sync <count> with every diff add/remove","Stream-validate all fileDiffEntries before ReverseXML","Never reuse partial output images after failures"],"tags":["hdfs","oiv","fsimage","reversexml","snapshot-diff","count-mismatch"],"backgroundTag":"xml-entry-count-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}