{"record":{"id":"541cb307794574f5","repo":"golang/go","slug":"s-s-v","errorCode":null,"errorMessage":"%s %s: %v","messagePattern":"%s %s: %v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modcmd/verify.go","lineNumber":124,"sourceCode":"\tdir, dirErr := modfetch.DownloadDir(ctx, mod)\n\tdata, err := os.ReadFile(zip + \"hash\")\n\tif err != nil {\n\t\tif zipErr != nil && errors.Is(zipErr, fs.ErrNotExist) &&\n\t\t\tdirErr != nil && errors.Is(dirErr, fs.ErrNotExist) {\n\t\t\t// Nothing downloaded yet. Nothing to verify.\n\t\t\treturn nil\n\t\t}\n\t\terrs = append(errs, fmt.Errorf(\"%s %s: missing ziphash: %v\", mod.Path, mod.Version, err))\n\t\treturn errs\n\t}\n\th := string(bytes.TrimSpace(data))\n\n\tif zipErr != nil && errors.Is(zipErr, fs.ErrNotExist) {\n\t\t// ok\n\t} else {\n\t\thZ, err := dirhash.HashZip(zip, dirhash.DefaultHash)\n\t\tif err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"%s %s: %v\", mod.Path, mod.Version, err))\n\t\t\treturn errs\n\t\t} else if hZ != h {\n\t\t\terrs = append(errs, fmt.Errorf(\"%s %s: zip has been modified (%v)\", mod.Path, mod.Version, zip))\n\t\t}\n\t}\n\tif dirErr != nil && errors.Is(dirErr, fs.ErrNotExist) {\n\t\t// ok\n\t} else {\n\t\thD, err := dirhash.HashDir(dir, mod.Path+\"@\"+mod.Version, dirhash.DefaultHash)\n\t\tif err != nil {\n\n\t\t\terrs = append(errs, fmt.Errorf(\"%s %s: %v\", mod.Path, mod.Version, err))\n\t\t\treturn errs\n\t\t}\n\t\tif hD != h {\n\t\t\terrs = append(errs, fmt.Errorf(\"%s %s: dir has been modified (%v)\", mod.Path, mod.Version, dir))\n\t\t}\n\t}","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modcmd/verify.go#L106-L142","documentation":"Thrown during `go mod verify` when `dirhash.HashZip` fails to compute the hash of the module's zip file. This wraps the underlying hashing error with the module path and version for identification. Hashing can fail if the zip file is corrupted, truncated, or otherwise unreadable.","triggerScenarios":"Running `go mod verify` where the zip file exists but is corrupted. `dirhash.HashZip(zip, dirhash.DefaultHash)` returns a non-nil error — e.g., the zip is truncated, has invalid internal structure, or there's an I/O error reading it.","commonSituations":"Corrupted download (network interruption during zip fetch); disk corruption; manual modification of the zip file; filesystem errors; partial writes from concurrent processes.","solutions":["Remove the specific module's cache entry and re-download: `go clean -modcache && go mod download`","Check disk health if corruption recurs across multiple modules","Ensure no concurrent processes are modifying GOMODCACHE"],"exampleFix":"// before\ngo mod verify  // fails hashing corrupt zip\n// after\ngo clean -modcache && go mod download && go mod verify","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// On zip hash failure, attempt cache cleanup and re-download\nif err := verifyModule(mod); err != nil {\n    goCleanModcache()\n    goModDownload(mod)\n    verifyModule(mod) // retry once\n}","preventionTips":["Use `go clean -modcache` to reset a corrupted cache rather than selective deletion","Monitor disk health in long-lived CI runners that cache modules","Avoid interrupting `go mod download` mid-transfer"],"tags":["go","go-mod","cache","verification","hashing","corruption"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}