Skip to content
Latchkey

Go "invalid version: unknown revision" - Fix in CI

Go resolves a module version to a real tag, commit, or pseudo-version. When the revision named in go.mod or on the command line does not exist upstream, resolution fails.

What this error means

A go get or build fails with invalid version: unknown revision vX.Y.Z. It means the tag was deleted or never existed, a branch was renamed, or a hand-written pseudo-version points at no commit.

go
go: github.com/foo/bar@v1.4.0: invalid version: unknown revision v1.4.0

Common causes

Tag or branch no longer exists

The referenced tag was deleted or the default branch was renamed, so the revision cannot be found.

Hand-written pseudo-version

A manually typed pseudo-version points at a commit that is not in the repository.

How to fix it

Pin a revision that exists

  1. List the real versions and require one that resolves.
  2. Run go mod tidy and commit.
Terminal
go list -m -versions github.com/foo/bar
go get github.com/foo/bar@v1.4.1
go mod tidy

Let go get generate the pseudo-version

  1. For an untagged commit, fetch by full SHA so Go computes a valid pseudo-version.
Terminal
go get github.com/foo/bar@<full-commit-sha>

How to prevent it

  • Pin full, published versions and avoid deleted tags.
  • Let go get generate pseudo-versions rather than typing them.
  • Verify a tag exists upstream before requiring it.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →