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.
[ERROR] v99.9.9 is not a valid https://github.com/psf/black rev
Check the log at /root/.cache/pre-commit/pre-commit.logCommon 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
- List the hook repo tags to find a valid release.
- Update
revto that exact tag. - Re-run so the checkout resolves.
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: blackLet autoupdate fix the pin
autoupdate rewrites each rev to the latest tag the repo actually publishes.
pre-commit autoupdateHow to prevent it
- Pin to immutable release tags, not branches.
- Run
pre-commit autoupdateon a schedule to keep revs valid. - Review autoupdate diffs before merging so pins stay intentional.