Go "invalid version: unknown revision" - Fix Bad Versions in CI
Go asked the source for a specific revision - a tag, branch, or commit hash - and the repository has no such revision. The version string in go.mod (or in a go get) does not exist upstream.
What this error means
A fetch fails with invalid version: unknown revision <ref>. It appears after pinning a tag that was deleted, a branch that was renamed, or a pseudo-version whose commit is no longer reachable.
go: github.com/org/lib@v1.7.3: invalid version:
unknown revision v1.7.3
# or a pseudo-version:
go: github.com/org/lib@v0.0.0-20240101000000-abcdef123456:
invalid version: unknown revision abcdef123456Common causes
A deleted or never-published tag
The tag the require pins was removed upstream or never existed, so the source has no revision matching that version.
A force-pushed branch or rebased history
A pseudo-version references a commit hash that a force-push or rebase made unreachable, so the revision can no longer be resolved.
A renamed branch behind a branch pseudo-version
Pinning to a branch (@main) that was renamed or deleted leaves Go unable to resolve the revision.
How to fix it
Pin a version that actually exists
List the real tags and move to one the repository still has.
go list -m -versions github.com/org/lib
go get github.com/org/lib@v1.7.0Re-resolve a moving branch to a fresh pseudo-version
When tracking a branch, re-resolve so the pseudo-version points at a commit that still exists.
go get github.com/org/lib@main
go mod tidyBypass a stale proxy cache for the revision
GOFLAGS=-mod=mod GOPROXY=direct go get github.com/org/lib@v1.7.3How to prevent it
- Depend on released tags rather than branches or raw commits.
- Avoid force-pushing tags that downstreams pin.
- Re-tidy after upstream history changes so pseudo-versions stay valid.