{"record":{"id":"485a297a9f45cf51","repo":"golang/go","slug":"ziphash-file-is-missing","errorCode":null,"errorMessage":"ziphash file is missing","messagePattern":"ziphash file is missing","errorType":"exception","errorClass":"DownloadDirPartialError","httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/cache.go","lineNumber":135,"sourceCode":"\n\t// Special case: ziphash is not required for the golang.org/fips140 module,\n\t// because it is unpacked from a file in GOROOT, not downloaded.\n\t// We've already checked that it's not a partial unpacking, so we're happy.\n\tif m.Path == \"golang.org/fips140\" {\n\t\treturn dir, nil\n\t}\n\n\t// Check if a .ziphash file exists. It should be created before the\n\t// zip is extracted, but if it was deleted (by another program?), we need\n\t// to re-calculate it. Note that checkMod will repopulate the ziphash\n\t// file if it doesn't exist, but if the module is excluded by checks\n\t// through GONOSUMDB or GOPRIVATE, that check and repopulation won't happen.\n\tziphashPath, err := CachePath(ctx, m, \"ziphash\")\n\tif err != nil {\n\t\treturn dir, err\n\t}\n\tif _, err := os.Stat(ziphashPath); os.IsNotExist(err) {\n\t\treturn dir, &DownloadDirPartialError{dir, errors.New(\"ziphash file is missing\")}\n\t} else if err != nil {\n\t\treturn dir, err\n\t}\n\treturn dir, nil\n}\n\n// DownloadDirPartialError is returned by DownloadDir if a module directory\n// exists but was not completely populated.\n//\n// DownloadDirPartialError is equivalent to fs.ErrNotExist.\ntype DownloadDirPartialError struct {\n\tDir string\n\tErr error\n}\n\nfunc (e *DownloadDirPartialError) Error() string     { return fmt.Sprintf(\"%s: %v\", e.Dir, e.Err) }\nfunc (e *DownloadDirPartialError) Is(err error) bool { return err == fs.ErrNotExist }\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/cache.go#L117-L153","documentation":"The .ziphash file records the hash of the module zip and must be written before extraction so integrity can be verified. If it does not exist (os.IsNotExist) while the directory and zip are present, DownloadDir returns a DownloadDirPartialError because the cache entry cannot be trusted without its hash.","triggerScenarios":"The .ziphash file for a cached module is absent while the module directory exists, so the integrity check cannot run.","commonSituations":"The .ziphash was deleted manually or by an overzealous cleanup tool; the cache was populated by an old go version that did not write ziphash; GONOSUMDB/GOPRIVE skipping the check that would repopulate the hash.","solutions":["Run `go clean -modcache` and re-download the module so the ziphash is regenerated.","Run `go mod verify` to surface affected modules, then re-download those specifically.","Avoid deleting individual metadata files inside GOMODCACHE; clean the whole cache if needed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify the ziphash exists before trusting a cached module:\n//   if _, err := os.Stat(ziphashPath); os.IsNotExist(err) {\n//     // re-download to regenerate the hash\n//   }","typeGuard":null,"tryCatchPattern":"// On DownloadDirPartialError(\"ziphash file is missing\"),\n// remove the cache entry and run `go mod download` to regenerate it.","preventionTips":["Do not delete individual metadata files inside GOMODCACHE.","Clean the whole cache with `go clean -modcache` rather than surgical edits."],"tags":["go","modules","cache","integrity","checksum"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}