Skip to content
Latchkey

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: rev

Common 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

  1. Read which key and which repo the error names.
  2. Add the required rev and hooks list, or fix the value type.
  3. Validate locally before pushing.
.pre-commit-config.yaml
repos:
  - repo: https://github.com/psf/black
    rev: 24.4.2
    hooks:
      - id: black

Validate 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.yaml

How to prevent it

  • Keep repo, rev, and hooks present on every remote entry.
  • Run pre-commit validate-config as an early CI step.
  • Use args: as a list, never a bare string.

Related guides

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