{"record":{"id":"0f3ae1db11f64403","repo":"lima-vm/lima","slug":"reading-omap-child-node-w","errorCode":null,"errorMessage":"reading omap child node: %w","messagePattern":"reading omap child node: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/apfs/chown.go","lineNumber":373,"sourceCode":"\t\t\tkeyStart := keyAreaStart + kOff\n\t\t\tentryOID := le.Uint64(blk[keyStart:])\n\t\t\tentryXID := le.Uint64(blk[keyStart+8:])\n\n\t\t\tcmp := compareOmapKey(entryOID, entryXID, oid, maxXID)\n\t\t\tif cmp <= 0 {\n\t\t\t\tchildIdx = i\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// Read child pointer (physical address, 8 bytes).\n\t\t_, vOff := c.readTocEntry(blk, tocStart, childIdx, isFixedKV)\n\t\tchildAddr := le.Uint64(blk[valueAreaEnd-vOff:])\n\n\t\tblk, err = c.readBlock(childAddr)\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"reading omap child node: %w\", err)\n\t\t}\n\t}\n}\n\n// readTocEntry reads the key and value offsets from a ToC entry.\n// For fixed-KV nodes (kvoff_t): 4 bytes per entry (k_off u16, v_off u16).\n// For variable-KV nodes (kvloc_t): 8 bytes per entry (k.off u16, k.len u16, v.off u16, v.len u16).\n// Returns keyOffset and valueOffset (both relative to their respective areas).\nfunc (c *container) readTocEntry(blk []byte, tocStart, index uint32, fixedKV bool) (keyOff, valOff uint32) {\n\tif fixedKV {\n\t\toff := tocStart + index*4\n\t\treturn uint32(le.Uint16(blk[off:])), uint32(le.Uint16(blk[off+2:]))\n\t}\n\toff := tocStart + index*8\n\treturn uint32(le.Uint16(blk[off:])), uint32(le.Uint16(blk[off+4:]))\n}\n\n// verifyBTreeNodeType checks that a block's object type indicates a","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/apfs/chown.go#L355-L391","documentation":"During descent through an internal omap B-tree node, omapLookup reads the child node at the physical address stored in the child pointer. This error wraps the readBlock failure for that child, meaning an I/O-level failure (typically EOF because the address lies past the end of the image) occurred before checksum or type validation could run.","triggerScenarios":"A corrupt or dangling child pointer inside an internal omap node, an image truncated so the child block is missing, or I/O errors reading that region of the disk file.","commonSituations":"Truncated/partial disk copies, images from crashed or still-running VMs with inconsistent trees, bad host storage, or corrupted images after an interrupted file transfer.","solutions":["Verify the image file size matches the source disk; re-copy if truncated.","Run fsck_apfs on the image from a macOS host to repair B-tree structure.","Re-export the image from a cleanly shut-down VM.","Check host disk health if I/O errors persist.","Restore from backup if corruption is confirmed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := apfs.Chown(diskPath, role, uid, gid, paths...); err != nil {\n\tif strings.Contains(err.Error(), \"reading omap child node\") {\n\t\treturn fmt.Errorf(\"omap tree is inconsistent or the image is truncated: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Verify image completeness (size + checksum) before processing.","Never read images that are concurrently being written.","Run fsck_apfs on suspicious images before programmatic edits.","Keep backups of images before write operations."],"tags":["apfs","btree","io-error"],"backgroundTag":"btree-child-read-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}