pre-commit "InvalidConfigError" in .pre-commit-config.yaml in CI
pre-commit loaded .pre-commit-config.yaml and it failed schema validation: a required field like repo or rev is absent, or a value is not the expected type. The message names the offending key.
What this error means
pre-commit aborts before running any hook with "InvalidConfigError:" and a description of the failing key, such as a missing rev or a hooks entry that is not a list.
pre-commit
An error has occurred: InvalidConfigError:
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='https://github.com/psf/black')
=====> Missing required key: revCommon causes
A required key is missing
Each remote repo entry needs repo, rev, and hooks. Omitting rev (or hooks) fails validation immediately.
A value has the wrong type
For example hooks given as a mapping instead of a list, or args as a string instead of a list, fails the schema.
How to fix it
Add the missing or corrected key
- Read which key and which repo the error names.
- Add the required
revandhookslist, or fix the value type. - Validate locally before pushing.
.pre-commit-config.yaml
repos:
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: blackValidate the config in CI
Run the built-in validator so a malformed config fails fast with a clear message.
Terminal
pre-commit validate-config .pre-commit-config.yamlHow to prevent it
- Keep
repo,rev, andhookspresent on every remote entry. - Run
pre-commit validate-configas an early CI step. - Use
args:as a list, never a bare string.
Related guides
pre-commit "InvalidManifestError" from a hook repo in CIFix pre-commit "InvalidManifestError" in CI - the hook repository pre-commit cloned has a .pre-commit-hooks.y…
pre-commit ".pre-commit-config.yaml: mapping values are not allowed here" in CIFix the YAML parse error "mapping values are not allowed here" in .pre-commit-config.yaml in CI - indentation…
pre-commit "Hook id ... not present in repo" in CIFix pre-commit "Hook id `X` not present in repository ..." in CI - the hook id in your config does not exist…