{"record":{"id":"42244202c658e1bf","repo":"golang/go","slug":"non-specific-origin","errorCode":null,"errorMessage":"non-specific origin","messagePattern":"non-specific origin","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmd/go/internal/modfetch/codehost/git.go","lineNumber":213,"sourceCode":"\nfunc (r *gitRepo) 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 != \"git\" || old.URL != r.remoteURL {\n\t\treturn fmt.Errorf(\"origin moved from %v %q to %v %q\", old.VCS, old.URL, \"git\", r.remoteURL)\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, \"git\", r.remoteURL, subdir)\n\t}\n\n\t// Note: Can have Hash with no Ref and no TagSum and no RepoSum,\n\t// meaning the Hash simply has to remain in the repo.\n\t// In that case we assume it does in the absence of any real way to check.\n\t// But if neither Hash nor TagSum is present, we have nothing to check,\n\t// which we take to mean we didn't record enough information to be sure.\n\tif old.Hash == \"\" && old.TagSum == \"\" && old.RepoSum == \"\" {\n\t\treturn fmt.Errorf(\"non-specific origin\")\n\t}\n\n\tr.loadRefs(ctx)\n\tif r.refsErr != nil {\n\t\treturn r.refsErr\n\t}\n\n\tif old.Ref != \"\" {\n\t\thash, ok := r.refs[old.Ref]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"ref %q deleted\", old.Ref)\n\t\t}\n\t\tif hash != old.Hash {\n\t\t\treturn fmt.Errorf(\"ref %q moved from %s to %s\", old.Ref, old.Hash, hash)\n\t\t}\n\t}\n\tif old.TagSum != \"\" {\n\t\ttags, err := r.Tags(ctx, old.TagPrefix)","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/codehost/git.go#L195-L231","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Clear the VCS cache to force a fresh clone with full metadata: 'go clean -cache'.","Upgrade to a current go version so newly written Origins include all fields.","If calling CheckReuse programmatically, ensure the Origin you pass has Hash or TagSum or RepoSum populated.","Treat this as a cache miss — the caller should re-fetch."],"exampleFix":"// before: Origin missing verification fields\nold := &codehost.Origin{VCS: \"git\", URL: url}\nerr := repo.CheckReuse(ctx, old, subdir)\n// after: populate at least one of Hash/TagSum/RepoSum\nold := &codehost.Origin{VCS: \"git\", URL: url, Hash: knownHash}\nerr := repo.CheckReuse(ctx, old, subdir)","handlingStrategy":"fallback","validationCode":"null","typeGuard":"// Type guard: an Origin is reusable only if it has verification data\nfunc isSpecificOrigin(o *codehost.Origin) bool {\n    if o == nil { return false }\n    return o.Hash != \"\" || o.TagSum != \"\" || o.RepoSum != \"\"\n}","tryCatchPattern":"// Treat non-specific origin as a cache miss and re-fetch\nerr := repo.CheckReuse(ctx, old, subdir)\nif err != nil && strings.Contains(err.Error(), \"non-specific origin\") {\n    // fall through to a full Stat/fetch\n    info, ferr := repo.Stat(ctx, rev)\n    if ferr != nil { return ferr }\n    return useInfo(info)\n}","preventionTips":["Always populate Hash or TagSum or RepoSum when constructing Origin for CheckReuse.","Clear the cache after major go version upgrades to refresh Origin metadata.","Don't call CheckReuse with hand-built Origin structs missing fields."],"tags":["git","cache-reuse","origin","metadata"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}