wagoodman/dive · error

unable to read file: %w

Error message

unable to read file: %w

What it means

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.

Source

Thrown at dive/filetree/file_info.go:130

	if data.TypeFlag == other.TypeFlag {
		if data.hash == other.hash &&
			data.Mode == other.Mode &&
			data.Uid == other.Uid &&
			data.Gid == other.Gid {
			return Unmodified
		}
	}
	return Modified
}

func getHashFromReader(reader io.Reader) uint64 {
	h := xxhash.New()

	buf := make([]byte, 1024)
	for {
		n, err := reader.Read(buf)
		if err != nil && err != io.EOF {
			panic(fmt.Errorf("unable to read file: %w", err))
		}
		if n == 0 {
			break
		}

		_, err = h.Write(buf[:n])
		if err != nil {
			panic(fmt.Errorf("unable to write to hash: %w", err))
		}
	}

	return h.Sum64()
}

View on GitHub (pinned to d6c691947f)

Solutions

  1. Retry the scan: transient EIO (NFS hiccup, concurrent truncation) often clears when the tree is stable
  2. Move/copy the data off the suspect mount and analyze the copy: rsync -a <src> <copy> will surface and localize read errors
  3. Check dmesg/storage health if the same path keeps failing: the medium or FUSE daemon is likely at fault
  4. Stabilize the directory (stop rotating/truncating processes) before analysis
Defensive patterns

Strategy: retry

Try / catch

// mid-stream read failures panic; if you wrap the reader yourself you can pre-read:
func readableEntirely(p string) bool {
    f, err := os.Open(p)
    if err != nil {
        return false
    }
    defer f.Close()
    _, err = io.Copy(io.Discard, f) // surfaces EIO/truncation before dive panics
    return err == nil
}

Prevention

When it happens

Trigger: 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).

Common situations: Scanning directories on flaky network mounts, scanning logs that rotate during the scan, or hardware/filesystem corruption. Rare on healthy local disks.

Related errors


AI-assisted analysis of wagoodman/dive@d6c691947f (2026-08-15). Data as JSON: /api/errors/049473cc3f8a6c91. Report an issue: GitHub.