Skip to content
Latchkey

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 output
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 abcdef123456

Common 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.

Terminal
go list -m -versions github.com/org/lib
go get github.com/org/lib@v1.7.0

Re-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.

Terminal
go get github.com/org/lib@main
go mod tidy

Bypass a stale proxy cache for the revision

Terminal
GOFLAGS=-mod=mod GOPROXY=direct go get github.com/org/lib@v1.7.3

How 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.

Frequently asked questions

What causes ""invalid version: unknown revision""?
The tag the require pins was removed upstream or never existed, so the source has no revision matching that version.
How do I fix "invalid version: unknown revision"?
List the real tags and move to one the repository still has.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card