{"record":{"id":"ea9e7d01a79de621","repo":"apache/hadoop","slug":"expected-to-find-createdlistsize-in-dirdiff-se","errorCode":null,"errorMessage":"Expected to find <createdListSize> in <dirDiff> section.","messagePattern":"Expected to find <createdListSize> in <dirDiff> section\\.","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":1481,"sourceCode":"          throw new IOException(\"Expected to find <childrenSize> in \" +\n              \"<dirDiff> section.\");\n        }\n        bld.setIsSnapshotRoot(dirDiff.removeChildBool(\n            SNAPSHOT_DIFF_SECTION_IS_SNAPSHOT_ROOT));\n        bld.setChildrenSize(childrenSize);\n        String name = dirDiff.removeChildStr(SECTION_NAME);\n        if (name != null) {\n          bld.setName(ByteString.copyFrom(name, StandardCharsets.UTF_8));\n        }\n        Node snapshotCopy = dirDiff.removeChild(\n            SNAPSHOT_DIFF_SECTION_SNAPSHOT_COPY);\n        if (snapshotCopy != null) {\n          bld.setSnapshotCopy(createINodeDirectoryBuilder(snapshotCopy));\n        }\n        Integer expectedCreatedListSize = dirDiff.removeChildInt(\n            SNAPSHOT_DIFF_SECTION_CREATED_LIST_SIZE);\n        if (expectedCreatedListSize == null) {\n          throw new IOException(\"Expected to find <createdListSize> in \" +\n              \"<dirDiff> section.\");\n        }\n        bld.setCreatedListSize(expectedCreatedListSize);\n        while (true) {\n          Node deleted = dirDiff.removeChild(\n              SNAPSHOT_DIFF_SECTION_DELETED_INODE);\n          if (deleted == null){\n            break;\n          }\n          bld.addDeletedINode(Long.parseLong(deleted.getVal()));\n        }\n        while (true) {\n          Node deleted = dirDiff.removeChild(\n              SNAPSHOT_DIFF_SECTION_DELETED_INODE_REF);\n          if (deleted == null){\n            break;\n          }\n          bld.addDeletedINodeRef(Integer.parseInt(deleted.getVal()));","sourceCodeStart":1463,"sourceCodeEnd":1499,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java#L1463-L1499","documentation":"A <dirDiff> element is missing <createdListSize>, the count of created-list entries that follow the diff header. The reconstructor needs it to set DirectoryDiff.createdListSize before scanning <created> entries, so its absence is fatal for this diff.","triggerScenarios":"A <dirDiff> where <createdListSize> was omitted, renamed, or moved inside a sibling element such as <snapshotCopy>; also diffs assembled by scripts that emit <created> entries but not the size field.","commonSituations":"Hand-edited diffs where created files were added/removed without touching the size field; template-based XML generation missing the field; version-skewed writers.","solutions":["Add <createdListSize>N</createdListSize> to the <dirDiff>, where N is the number of <created> children that follow","Verify it is a direct child of <dirDiff>, spelled exactly 'createdListSize'","Cross-check N against the actual <created> entries to avoid the follow-on count-mismatch error","Regenerate the XML with a same-version oiv when in doubt"],"exampleFix":"<!-- before -->\n<dirDiff><snapshotId>3</snapshotId><childrenSize>5</childrenSize></dirDiff>\n<!-- after -->\n<dirDiff><snapshotId>3</snapshotId><childrenSize>5</childrenSize><createdListSize>0</createdListSize></dirDiff>","handlingStrategy":"validation","validationCode":"# python: every <dirDiff> needs <createdListSize>\nimport xml.etree.ElementTree as ET\n\ndef dirdiffs_have_createdlistsize(path):\n    for ev, el in ET.iterparse(path, events=('end',)):\n        if el.tag == 'dirDiff' and el.find('createdListSize') is None:\n            return False\n    return True","typeGuard":null,"tryCatchPattern":"// catch oiv failure naming <createdListSize>; set it to the number of\n// <created> children, remove partial output, re-run","preventionTips":["Always emit <createdListSize> alongside any <created> entries (0 when none)","Keep the value synced with the actual entry count","Validate both presence and consistency pre-flight","Regenerate rather than guess unknown values"],"tags":["hdfs","oiv","fsimage","reversexml","snapshot-diff","missing-field"],"backgroundTag":"missing-required-xml-element","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}