{"record":{"id":"6d5245cdc7987fd6","repo":"wagoodman/dive","slug":"unable-to-write-to-hash-w","errorCode":null,"errorMessage":"unable to write to hash: %w","messagePattern":"unable to write to hash: %w","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"dive/filetree/file_info.go","lineNumber":138,"sourceCode":"\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":120,"sourceCodeEnd":144,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/dive/filetree/file_info.go#L120-L144","documentation":"Raised as a panic in getHashFromReader (dive/filetree/file_info.go:138) if h.Write on an xxhash.Digest returns an error. Go's xxhash Digest.Write never returns a non-nil error, so in practice this branch is unreachable defensive code.","triggerScenarios":"Only reachable if the hash implementation is swapped for one whose Write can fail (a wrapping/tee writer with a failing downstream), or via memory corruption. With the vendored github.com/cespare/xxhash it does not occur.","commonSituations":"Effectively never seen in the wild. If reported, it usually indicates a modified fork of dive or a corrupted binary rather than a runtime condition.","solutions":["Treat a report of this panic as a build-integrity question: confirm you are running unmodified dive and a stock xxhash dependency","If you forked getHashFromReader with a failing writer (e.g. a tee to disk), fix or remove the failing writer - xxhash itself cannot fail","Not actionable at the call site: there is no input that legitimately triggers it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Practically unreachable with the vendored xxhash - no caller-side defense needed","If you fork getHashFromReader, keep the writer error-free (xxhash.Write cannot fail)","Treat any occurrence as a build-integrity problem (modified binary/deps), not a runtime input problem"],"tags":["hashing","panic","defensive-code","unreachable"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}