golang/go · error
looking up hash: %v
Error message
looking up hash: %v
What it means
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.
Source
Thrown at src/cmd/go/internal/modfetch/codehost/vcs.go:398
func (r *vcsRepo) CheckReuse(ctx context.Context, old *Origin, subdir string) error {
if old == nil {
return fmt.Errorf("missing origin")
}
if old.VCS != r.cmd.vcs || old.URL != r.remote {
return fmt.Errorf("origin moved from %v %q to %v %q", old.VCS, old.URL, r.cmd.vcs, r.remote)
}
if old.Subdir != subdir {
return fmt.Errorf("origin moved from %v %q %q to %v %q %q", old.VCS, old.URL, old.Subdir, r.cmd.vcs, r.remote, subdir)
}
if old.Ref == "" && old.RepoSum == "" && old.Hash != "" {
// Hash has to remain in repo.
hash, err := r.lookupRef(ctx, old.Hash)
if err == nil && hash == old.Hash {
return nil
}
if err != nil {
return fmt.Errorf("looking up hash: %v", err)
}
return fmt.Errorf("hash changed") // weird but maybe they made a tag
}
if old.Ref != "" && old.RepoSum == "" {
hash, err := r.lookupRef(ctx, old.Ref)
if err == nil && hash != "" && hash == old.Hash {
return nil
}
}
r.repoSumOnce.Do(func() { r.loadRepoSum(ctx) })
if r.repoSum != "" {
if old.RepoSum == "" {
return fmt.Errorf("non-specific origin")
}
if old.RepoSum != r.repoSum {
return fmt.Errorf("repo changed")View on GitHub (pinned to b6b368adc5)
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.
Defensive patterns
Strategy: retry
Try / catch
hash, err := r.lookupRef(ctx, old.Hash)
if err != nil {
// transient network or unsupported-VCS error — fall back to full re-download
return fmt.Errorf("looking up hash: %w", err)
} Prevention
- 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).
When it happens
Trigger: 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.
Common situations: 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').
Related errors
- hash changed
- no lookupRef
- missing origin
- origin moved from %v %q to %v %q
- origin moved from %v %q %q to %v %q %q
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/f8959c466aafe1a3.
Report an issue: GitHub.