{"record":{"id":"2bacd51c9133988e","repo":"golang/go","slug":"ref-q-deleted","errorCode":null,"errorMessage":"ref %q deleted","messagePattern":"ref %q deleted","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/codehost/git.go","lineNumber":224,"sourceCode":"\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)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif tags.Origin.TagSum != old.TagSum {\n\t\t\treturn fmt.Errorf(\"tags changed\")\n\t\t}\n\t}\n\tif old.RepoSum != \"\" {\n\t\tif r.repoSum(r.refs) != old.RepoSum {\n\t\t\treturn fmt.Errorf(\"refs changed\")\n\t\t}","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/codehost/git.go#L206-L242","documentation":"Thrown by gitRepo.CheckReuse when the previously recorded ref (old.Ref) no longer exists in the remote's ref set (loaded via ls-remote). This means the branch or tag that the cached checkout was based on has been deleted upstream, so the cached data may no longer be reachable.","triggerScenarios":"CheckReuse after the upstream deleted the branch/tag that old.Ref pointed to (e.g. a feature branch merged and removed, or a tag was deleted). The local refs map from ls-remote no longer contains old.Ref.","commonSituations":"A module pinned to a branch that was deleted upstream; a tag removed and recreated; force-push history rewrite that dropped the ref; GitHub auto-deleting branches after merge.","solutions":["Update the module to a version that exists: 'go get module@<tag-or-hash>'.","If the ref was renamed, update your dependency to the new ref.","Pin to a specific commit hash or a semantic version tag instead of a mutable branch.","Contact the module maintainer if the ref was deleted unintentionally."],"exampleFix":"// before: pinned to a deleted branch\ngo get example.com/mod@some-branch\n// after: pin to a tag or hash\ngo get example.com/mod@v1.2.3\n// or\ngo get example.com/mod@abc123def456","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"// On 'ref deleted', fall back to a fresh Stat which may find the commit by hash\nerr := repo.CheckReuse(ctx, old, subdir)\nif err != nil && strings.Contains(err.Error(), \"deleted\") {\n    info, ferr := repo.Stat(ctx, old.Hash)\n    if ferr == nil { return useInfo(info) }\n    return ferr\n}","preventionTips":["Pin dependencies to immutable tags or commit hashes, not branches.","When upstream deletes a ref, update your dependency promptly.","Use 'go get module@<tag>' instead of '@<branch>' in production."],"tags":["git","cache-reuse","ref-deleted","upstream-change"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}