{"record":{"id":"1cea4beb80641ab0","repo":"golang/go","slug":"resolves-to-version-v-s-is-not-a-tag","errorCode":null,"errorMessage":"resolves to version %v (%s is not a tag)","messagePattern":"resolves to version (.+?) \\((.+?) is not a tag\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/coderepo.go","lineNumber":514,"sourceCode":"\t\t\t\t\terrIncompatible = invalidf(\"module path includes a major version suffix, so major version must match\")\n\t\t\t\t} else {\n\t\t\t\t\terrIncompatible = invalidf(\"module contains a go.mod file, so module path must match major version (%q)\", path.Join(r.pathPrefix, semver.Major(v)))\n\t\t\t\t}\n\t\t\t}\n\t\t} else if strings.HasSuffix(v, \"+incompatible\") {\n\t\t\terrIncompatible = invalidf(\"+incompatible suffix not allowed: major version %s is compatible\", semver.Major(v))\n\t\t}\n\n\t\tif statVers != \"\" && statVers == module.CanonicalVersion(statVers) {\n\t\t\t// Since the caller-requested version is canonical, it would be very\n\t\t\t// confusing to resolve it to anything but itself, possibly with a\n\t\t\t// \"+incompatible\" suffix. Error out explicitly.\n\t\t\tif statBase := strings.TrimSuffix(statVers, \"+incompatible\"); statBase != base {\n\t\t\t\treturn nil, &module.ModuleError{\n\t\t\t\t\tPath: r.modPath,\n\t\t\t\t\tErr: &module.InvalidVersionError{\n\t\t\t\t\t\tVersion: statVers,\n\t\t\t\t\t\tErr:     fmt.Errorf(\"resolves to version %v (%s is not a tag)\", v, statBase),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif errIncompatible != nil {\n\t\t\treturn nil, errIncompatible\n\t\t}\n\n\t\treturn &RevInfo{\n\t\t\tName:    info.Name,\n\t\t\tShort:   info.Short,\n\t\t\tTime:    info.Time,\n\t\t\tVersion: v,\n\t\t}, nil\n\t}\n\n\t// Determine version.","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L496-L532","documentation":"Thrown by codeRepo.Stat when the caller requested a canonical version string (one that equals its own CanonicalVersion), but resolving that revision against the VCS produced a different base version. The guard at coderepo.go:505-517 fires because a canonical request must resolve to itself (optionally with +incompatible); silently mapping it to a pseudo-version or other tag would be ambiguous. The (%s is not a tag) clause names statBase (the requested version with +incompatible stripped) to signal that the resolved tag does not literally exist in the repo under that name.","triggerScenarios":"Calling go get / module fetch with a version like v1.2.3 when the repo has no v1.2.3 tag but the revision is reachable (e.g. via a pseudo-version resolution path); statVers is canonical and statBase != base after incompatible handling. Also triggered by module proxies that canonicalize a request then fail to find the matching tag.","commonSituations":"A module consumer pins a version that was never tagged (only exists as a commit); tags were renamed or deleted upstream; using a fork via replace where the fork lacks the original's tags; proxy/goproxy cache returning a resolved revision that disagrees with the requested canonical version.","solutions":["Replace the requested canonical version with the correct pseudo-version (run `go list -m -versions <module>` to see available tags, or `go get <module>@<commit-hash>` to let the tooling derive the canonical pseudo-version).","If you own the module, create the missing tag (e.g. `git tag v1.2.3 && git push --tags`) so the canonical version resolves to itself.","For a replace directive pointing at a fork, ensure the fork publishes the same tags or pin to an explicit commit/pseudo-version.","Clear the local module cache (`go clean -modcache`) and retry in case a stale proxy result is involved."],"exampleFix":"// before\nrequire example.com/m v1.2.3   // v1.2.3 was never tagged\n\n// after (let tooling resolve)\ngo get example.com/m@e3702bed3d42e03e85e3a1e6b1a5a3d2\n// resulting in a pseudo-version such as\nrequire example.com/m v1.2.3-0.20240101120000-e3702bed3d42","handlingStrategy":"validation","validationCode":"// Before pinning, confirm the requested version is a real tag.\n// bash:\n//   git ls-remote --tags <repo-url> | grep -F 'refs/tags/v1.2.3'\n//\n// In Go tooling, prefer letting the resolver derive the version:\n//   go get example.com/m@<commit-sha>     // emits the correct version string\n// Avoid hand-writing canonical versions that may not be tagged.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always resolve versions via `go get <module>@<commit-or-tag>` rather than hand-editing go.mod.","When forking or replacing, replicate upstream tags or pin to explicit commits.","Run `go list -m -versions <module>` to see which versions are real tags before pinning."],"tags":["go-modules","version-resolution","pseudo-version","vcs-tags"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}