Skip to content
Latchkey

pre-commit "[ERROR] ... is not a valid ... rev" in CI

pre-commit cloned the hook repo but the rev you pinned is not a real tag or commit there, so the checkout fails. A typo, a deleted tag, or a moved default branch is the usual cause.

What this error means

The run fails early with "[ERROR] <rev> is not a valid <repo> rev" or a git checkout error naming the missing revision.

pre-commit
[ERROR] v99.9.9 is not a valid https://github.com/psf/black rev
Check the log at /root/.cache/pre-commit/pre-commit.log

Common causes

The pinned tag does not exist

You wrote a rev that was never published, or a maintainer removed or renamed the tag, so there is nothing to check out.

A branch name was used where a tag is expected

Pinning to a moving branch that was later deleted or renamed leaves the rev unresolvable.

How to fix it

Pin to a real published tag

  1. List the hook repo tags to find a valid release.
  2. Update rev to that exact tag.
  3. Re-run so the checkout resolves.
.pre-commit-config.yaml
- repo: https://github.com/psf/black
  rev: 24.4.2
  hooks:
    - id: black

Let autoupdate fix the pin

autoupdate rewrites each rev to the latest tag the repo actually publishes.

Terminal
pre-commit autoupdate

How to prevent it

  • Pin to immutable release tags, not branches.
  • Run pre-commit autoupdate on a schedule to keep revs valid.
  • Review autoupdate diffs before merging so pins stay intentional.

Related guides

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