{"record":{"id":"f8959c466aafe1a3","repo":"golang/go","slug":"looking-up-hash-v","errorCode":null,"errorMessage":"looking up hash: %v","messagePattern":"looking up hash: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/codehost/vcs.go","lineNumber":398,"sourceCode":"func (r *vcsRepo) CheckReuse(ctx context.Context, old *Origin, subdir string) error {\n\tif old == nil {\n\t\treturn fmt.Errorf(\"missing origin\")\n\t}\n\tif old.VCS != r.cmd.vcs || old.URL != r.remote {\n\t\treturn fmt.Errorf(\"origin moved from %v %q to %v %q\", old.VCS, old.URL, r.cmd.vcs, r.remote)\n\t}\n\tif old.Subdir != subdir {\n\t\treturn fmt.Errorf(\"origin moved from %v %q %q to %v %q %q\", old.VCS, old.URL, old.Subdir, r.cmd.vcs, r.remote, subdir)\n\t}\n\n\tif old.Ref == \"\" && old.RepoSum == \"\" && old.Hash != \"\" {\n\t\t// Hash has to remain in repo.\n\t\thash, err := r.lookupRef(ctx, old.Hash)\n\t\tif err == nil && hash == old.Hash {\n\t\t\treturn nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"looking up hash: %v\", err)\n\t\t}\n\t\treturn fmt.Errorf(\"hash changed\") // weird but maybe they made a tag\n\t}\n\n\tif old.Ref != \"\" && old.RepoSum == \"\" {\n\t\thash, err := r.lookupRef(ctx, old.Ref)\n\t\tif err == nil && hash != \"\" && hash == old.Hash {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tr.repoSumOnce.Do(func() { r.loadRepoSum(ctx) })\n\tif r.repoSum != \"\" {\n\t\tif old.RepoSum == \"\" {\n\t\t\treturn fmt.Errorf(\"non-specific origin\")\n\t\t}\n\t\tif old.RepoSum != r.repoSum {\n\t\t\treturn fmt.Errorf(\"repo changed\")","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/codehost/vcs.go#L380-L416","documentation":"In the hash-verification branch of CheckReuse (old has Hash but no Ref/RepoSum), lookupRef is called to confirm the hash is still present. If lookupRef itself errors, that error is wrapped here with %v. The underlying cause is typically a network failure, missing ref, or a 'no lookupRef' sentinel for unsupported VCS types.","triggerScenarios":"CheckReuse with old.Hash set and old.Ref/RepoSum empty; lookupRef fails — VCS command errored, hash not found on remote, or VCS lacks lookupRef support.","commonSituations":"Network blip during reuse verification; the upstream commit was garbage-collected or force-pushed away; an svn/fossil repo where lookupRef is unimplemented (then the wrapped error is 'no lookupRef').","solutions":["Retry the go command — transient network errors during lookupRef are common.","If the hash truly no longer exists upstream, the module is no longer available at that commit; pin a tag instead.","For svn/fossil, switch to GOPROXY to avoid the unsupported lookupRef path.","`go clean -modcache` to force re-resolution from scratch."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"hash, err := r.lookupRef(ctx, old.Hash)\nif err != nil {\n    // transient network or unsupported-VCS error — fall back to full re-download\n    return fmt.Errorf(\"looking up hash: %w\", err)\n}","preventionTips":["Pin modules to tags rather than bare hashes so the hash-verification branch is avoided.","Ensure network reachability for the remote before relying on CheckReuse.","Prefer VCS types that implement lookupRef (git, hg)."],"tags":["vcs","checkreuse","network","hash","lookupref"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}