golang/go · warning

non-specific origin

Error message

non-specific origin

What it means

Thrown by gitRepo.CheckReuse when the recorded Origin has no Hash, no TagSum, and no RepoSum — there is not enough recorded information to verify that the cached checkout is still valid. CheckReuse is called to decide whether a cached repo can be reused without re-fetching.

Source

Thrown at src/cmd/go/internal/modfetch/codehost/git.go:213

func (r *gitRepo) CheckReuse(ctx context.Context, old *Origin, subdir string) error {
	if old == nil {
		return fmt.Errorf("missing origin")
	}
	if old.VCS != "git" || old.URL != r.remoteURL {
		return fmt.Errorf("origin moved from %v %q to %v %q", old.VCS, old.URL, "git", r.remoteURL)
	}
	if old.Subdir != subdir {
		return fmt.Errorf("origin moved from %v %q %q to %v %q %q", old.VCS, old.URL, old.Subdir, "git", r.remoteURL, subdir)
	}

	// Note: Can have Hash with no Ref and no TagSum and no RepoSum,
	// meaning the Hash simply has to remain in the repo.
	// In that case we assume it does in the absence of any real way to check.
	// But if neither Hash nor TagSum is present, we have nothing to check,
	// which we take to mean we didn't record enough information to be sure.
	if old.Hash == "" && old.TagSum == "" && old.RepoSum == "" {
		return fmt.Errorf("non-specific origin")
	}

	r.loadRefs(ctx)
	if r.refsErr != nil {
		return r.refsErr
	}

	if old.Ref != "" {
		hash, ok := r.refs[old.Ref]
		if !ok {
			return fmt.Errorf("ref %q deleted", old.Ref)
		}
		if hash != old.Hash {
			return fmt.Errorf("ref %q moved from %s to %s", old.Ref, old.Hash, hash)
		}
	}
	if old.TagSum != "" {
		tags, err := r.Tags(ctx, old.TagPrefix)

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Clear the VCS cache to force a fresh clone with full metadata: 'go clean -cache'.
  2. Upgrade to a current go version so newly written Origins include all fields.
  3. If calling CheckReuse programmatically, ensure the Origin you pass has Hash or TagSum or RepoSum populated.
  4. Treat this as a cache miss — the caller should re-fetch.

Example fix

// before: Origin missing verification fields
old := &codehost.Origin{VCS: "git", URL: url}
err := repo.CheckReuse(ctx, old, subdir)
// after: populate at least one of Hash/TagSum/RepoSum
old := &codehost.Origin{VCS: "git", URL: url, Hash: knownHash}
err := repo.CheckReuse(ctx, old, subdir)
Defensive patterns

Strategy: fallback

Validate before calling

null

Type guard

// Type guard: an Origin is reusable only if it has verification data
func isSpecificOrigin(o *codehost.Origin) bool {
    if o == nil { return false }
    return o.Hash != "" || o.TagSum != "" || o.RepoSum != ""
}

Try / catch

// Treat non-specific origin as a cache miss and re-fetch
err := repo.CheckReuse(ctx, old, subdir)
if err != nil && strings.Contains(err.Error(), "non-specific origin") {
    // fall through to a full Stat/fetch
    info, ferr := repo.Stat(ctx, rev)
    if ferr != nil { return ferr }
    return useInfo(info)
}

Prevention

When it happens

Trigger: CheckReuse(ctx, old, subdir) where old.Origin lacks all three verification fields. This can happen with cache entries written by very old go versions, entries that were partially written/corrupted, or code paths that record an Origin without full metadata.

Common situations: Cache entries from a much older go version that didn't record RepoSum; a crash mid-write leaving an incomplete .info; manual cache manipulation; a custom proxy or tool producing Origin structs without all fields.

Related errors


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