Skip to content
Latchkey

pre-commit "check-added-large-files" fails in CI

The check-added-large-files hook from pre-commit-hooks flags any file over its size threshold (default 500 KB). In CI it fails because a large artifact or binary was committed to the repo.

What this error means

The hook prints "Failed" and names a file with its size, for example "app.bin (1234 KB) exceeds 500 KB".

pre-commit
check for added large files.................................Failed
- hook id: check-added-large-files
- exit code: 1

data/model.bin (5321 KB) exceeds 500 KB.

Diagnose it: did the report reach the service?

Coverage and quality integrations fail in two distinct places: the report was never produced, or it was produced and the upload was rejected. Establish which before touching tokens.

Terminal
# 1. does the report exist and is it non-empty?
ls -la coverage/ && head -5 coverage/lcov.info

# 2. does it reference paths the service can map to the repo?
grep "^SF:" coverage/lcov.info | head -5

# 3. did the upload actually succeed, or just not fail the step?
# most uploaders exit 0 on a rejected upload unless told otherwise

Common causes

A large binary or artifact was committed

A build output, dataset, or media file over the limit was added to git and the hook catches it.

The default threshold is lower than intended

A legitimately larger asset trips the default 500 KB limit that was never raised for the repo.

How to fix it

Remove the large file or track it with LFS

  1. Remove the oversized file from git history or move it to Git LFS.
  2. Add it to .gitignore if it is a build artifact.
  3. Re-run so the hook passes.
Terminal
git rm --cached data/model.bin
git lfs track "data/*.bin"

Raise the limit deliberately if needed

If larger files are expected, set an explicit maxkb via args.

.pre-commit-config.yaml
- id: check-added-large-files
  args: ['--maxkb=1024']

How to prevent it

  • Ignore build artifacts so they are never committed.
  • Use Git LFS for legitimately large assets.
  • Set an explicit --maxkb that matches your repo policy.

Frequently asked questions

What causes pre-commit "check-added-large-files" fails in CI?
There are 2 common causes: a large binary or artifact was committed and the default threshold is lower than intended. A build output, dataset, or media file over the limit was added to git and the hook catches it.
How do I fix pre-commit "check-added-large-files" fails in CI?
There are 2 fixes depending on which cause you have: remove the large file or track it with lfs and raise the limit deliberately if needed. Work through them in order, since the first is the most common.
What does pre-commit "check-added-large-files" fails in CI actually mean?
The hook prints "Failed" and names a file with its size, for example "app.bin (1234 KB) exceeds 500 KB".
How do I stop pre-commit "check-added-large-files" fails in CI happening again?
Ignore build artifacts so they are never committed. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card