golang/go · warning

no lookupRef

Error message

no lookupRef

What it means

vcsRepo.lookupRef returns this when the active vcsCmd has no lookupRef function. The svn and fossil command descriptors do not define lookupRef, so any CheckReuse path that needs to resolve a hash by ref fails immediately with this sentinel.

Source

Thrown at src/cmd/go/internal/modfetch/codehost/vcs.go:359

func (r *vcsRepo) loadRepoSum(ctx context.Context) {
	if r.cmd.repoSum == nil {
		return
	}
	where := r.remote
	if r.fetched.Load() {
		where = "." // use local repo
	}
	out, err := Run(ctx, r.dir, r.cmd.repoSum(where))
	if err != nil {
		return
	}
	r.repoSum = strings.TrimSpace(string(out))
}

func (r *vcsRepo) lookupRef(ctx context.Context, ref string) (string, error) {
	if r.cmd.lookupRef == nil {
		return "", fmt.Errorf("no lookupRef")
	}
	out, err := Run(ctx, r.dir, r.cmd.lookupRef(r.remote, ref))
	if err != nil {
		return "", err
	}
	return strings.TrimSpace(string(out)), nil
}

// repoSumOrigin returns an Origin containing a RepoSum.
func (r *vcsRepo) repoSumOrigin(ctx context.Context) *Origin {
	origin := &Origin{
		VCS:     r.cmd.vcs,
		URL:     r.remote,
		RepoSum: r.repoSum,
	}
	r.repoSumOnce.Do(func() { r.loadRepoSum(ctx) })
	origin.RepoSum = r.repoSum
	return origin

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Use the module proxy (GOPROXY) which bypasses the VCS lookupRef path entirely.
  2. Run `go clean -modcache` to drop the un-verifiable origin record so a fresh one is created.
  3. Migrate the upstream repo to git, which fully implements lookupRef.
Defensive patterns

Strategy: validation

Validate before calling

func supportsLookupRef(vcs string) bool {
    return vcs == "git" || vcs == "hg"
}

Prevention

When it happens

Trigger: CheckReuse calls lookupRef on a svn or fossil repo (cmd.lookupRef==nil) when old.Ref or old.Hash needs verification — e.g. an origin record with a Ref but no RepoSum for a fossil-backed module.

Common situations: A fossil or svn vanity import whose cached origin lacks a RepoSum, forcing the hash-verification branch in CheckReuse which then needs lookupRef that those VCS types do not implement.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/2b00772184afb0c7. Report an issue: GitHub.