Skip to content
Latchkey

pre-commit "check-yaml...Failed" in CI

The pre-commit check-yaml hook loads every staged YAML file. When one does not parse, the hook prints "Failed" with the parser error and the file, and the run exits non-zero.

What this error means

pre-commit output shows "check-yaml...............Failed" followed by the YAML parse error and the offending filename.

pre-commit
check-yaml...............................................................Failed
- hook id: check-yaml
- exit code: 1

config.yaml: could not determine a constructor for the tag '!Ref'
mapping values are not allowed here
  in "config.yaml", line 6, column 12

Common causes

A genuine YAML syntax error

A tab, bad indentation, an unquoted colon, or a duplicate key stops the parser, exactly as it would in any consumer.

Custom tags the loader rejects

CloudFormation !Ref/!GetAtt or other custom tags fail the default safe loader unless --unsafe is set to allow syntax-only checking.

How to fix it

Fix the reported YAML

  1. Open the file at the line:column in the hook output.
  2. Correct the syntax (quote colons, remove tabs, dedupe keys).
  3. Re-run pre-commit run check-yaml --all-files.
Terminal
pre-commit run check-yaml --all-files

Allow custom tags with --unsafe

For CloudFormation and similar custom tags, pass --unsafe so check-yaml validates syntax without resolving the tags.

.pre-commit-config.yaml
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v4.6.0
  hooks:
    - id: check-yaml
      args: [--unsafe]

How to prevent it

  • Run pre-commit locally so YAML errors never reach CI.
  • Use --unsafe only for files with legitimate custom tags.
  • Pair check-yaml with yamllint for style plus syntax.

Frequently asked questions

What causes ""check-yaml...Failed""?
A tab, bad indentation, an unquoted colon, or a duplicate key stops the parser, exactly as it would in any consumer.
How do I fix "check-yaml...Failed"?
Fix the reported YAML

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card