{"record":{"id":"049473cc3f8a6c91","repo":"wagoodman/dive","slug":"unable-to-read-file-w","errorCode":null,"errorMessage":"unable to read file: %w","messagePattern":"unable to read file: %w","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dive/filetree/file_info.go","lineNumber":130,"sourceCode":"\tif data.TypeFlag == other.TypeFlag {\n\t\tif data.hash == other.hash &&\n\t\t\tdata.Mode == other.Mode &&\n\t\t\tdata.Uid == other.Uid &&\n\t\t\tdata.Gid == other.Gid {\n\t\t\treturn Unmodified\n\t\t}\n\t}\n\treturn Modified\n}\n\nfunc getHashFromReader(reader io.Reader) uint64 {\n\th := xxhash.New()\n\n\tbuf := make([]byte, 1024)\n\tfor {\n\t\tn, err := reader.Read(buf)\n\t\tif err != nil && err != io.EOF {\n\t\t\tpanic(fmt.Errorf(\"unable to read file: %w\", err))\n\t\t}\n\t\tif n == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\t_, err = h.Write(buf[:n])\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf(\"unable to write to hash: %w\", err))\n\t\t}\n\t}\n\n\treturn h.Sum64()\n}\n","sourceCodeStart":112,"sourceCodeEnd":144,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/dive/filetree/file_info.go#L112-L144","documentation":"Raised as a panic inside getHashFromReader (dive/filetree/file_info.go:130). While streaming a file into xxhash in 1KB chunks, any reader.Read error other than io.EOF panics with 'unable to read file: %w'. This fires after the file was successfully opened, i.e. the failure is mid-stream, not at open time.","triggerScenarios":"An I/O error while reading: file truncated after open (log rotation, concurrent write), EIO from a failing disk or FUSE mount, or an unreadable file on a network filesystem that fails after open (NFS stale handle).","commonSituations":"Scanning directories on flaky network mounts, scanning logs that rotate during the scan, or hardware/filesystem corruption. Rare on healthy local disks.","solutions":["Retry the scan: transient EIO (NFS hiccup, concurrent truncation) often clears when the tree is stable","Move/copy the data off the suspect mount and analyze the copy: rsync -a <src> <copy> will surface and localize read errors","Check dmesg/storage health if the same path keeps failing: the medium or FUSE daemon is likely at fault","Stabilize the directory (stop rotating/truncating processes) before analysis"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// mid-stream read failures panic; if you wrap the reader yourself you can pre-read:\nfunc readableEntirely(p string) bool {\n    f, err := os.Open(p)\n    if err != nil {\n        return false\n    }\n    defer f.Close()\n    _, err = io.Copy(io.Discard, f) // surfaces EIO/truncation before dive panics\n    return err == nil\n}","preventionTips":["Avoid scanning over NFS/FUSE mounts when a local copy is possible","Ensure no process truncates/rotates files during the scan window","Retry once on failure - transient EIO conditions often clear"],"tags":["io","hashing","panic","filesystem","nfs"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}