{"record":{"id":"58105823c6ca52a4","repo":"golang/go","slug":"missing-origin","errorCode":null,"errorMessage":"missing origin","messagePattern":"missing origin","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/codehost/vcs.go","lineNumber":382,"sourceCode":"\t}\n\treturn strings.TrimSpace(string(out)), nil\n}\n\n// repoSumOrigin returns an Origin containing a RepoSum.\nfunc (r *vcsRepo) repoSumOrigin(ctx context.Context) *Origin {\n\torigin := &Origin{\n\t\tVCS:     r.cmd.vcs,\n\t\tURL:     r.remote,\n\t\tRepoSum: r.repoSum,\n\t}\n\tr.repoSumOnce.Do(func() { r.loadRepoSum(ctx) })\n\torigin.RepoSum = r.repoSum\n\treturn origin\n}\n\nfunc (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","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/codehost/vcs.go#L364-L400","documentation":"vcsRepo.CheckReuse guards against a nil old origin at the top of the function. Callers must supply a previously-recorded Origin to compare against; passing nil means there is nothing to reuse.","triggerScenarios":"CheckReuse invoked with old==nil — usually a caller bug where the cached origin was never persisted, was deserialised from a corrupt cache entry, or the caller is probing for reusability without a baseline.","commonSituations":"A corrupted module cache where the origin blob was deleted but the unpacked module remains; a codehost client wrapper that lazily passes nil when no prior download is recorded.","solutions":["Run `go clean -modcache` to remove the orphaned module directory so the go command re-downloads with a fresh origin.","Audit the caller to ensure a non-nil Origin is always supplied (this is an internal-API contract, not a user-facing knob).","Verify the cache layout under GOMODCACHE/cache/download/<module>/@v/ — a missing .info or .origin file indicates an interrupted download."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func hasOrigin(o *codehost.Origin) bool { return o != nil }","tryCatchPattern":"if err := repo.CheckReuse(ctx, old, subdir); err != nil {\n    if strings.Contains(err.Error(), \"missing origin\") {\n        // treat as cache miss, re-download instead of failing\n        old = nil\n    }\n}","preventionTips":["Always persist the Origin alongside the downloaded module so CheckReuse has a baseline.","Treat 'missing origin' as a soft cache miss rather than a hard failure."],"tags":["vcs","checkreuse","cache","internal-api"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}