Skip to content
Latchkey

GitHub Actions hashFiles glob matches nothing and produces an empty cache key

hashFiles(pattern) returns a hash of the matched files, or an empty string when nothing matches. An empty hash collapses a cache key like deps-${{ hashFiles(...) }} into deps-, which never restores the intended cache and may collide.

What this error means

The cache never hits and the resolved key is just the static prefix with an empty hash segment.

github-actions
key: deps-${{ hashFiles('**/package-lock.json') }}
# package-lock.json is missing -> hashFiles returns '' -> key resolves to 'deps-'

Common causes

Lockfile path does not exist

A wrong glob or a repo without the lockfile makes hashFiles match nothing and return empty.

Checkout did not include the file

A sparse or filtered checkout can exclude the file the glob expects.

How to fix it

Point hashFiles at a file that exists

  1. Verify the glob matches at least one tracked file in the repo.
  2. List candidate files in a debug step to confirm the path.
.github/workflows/ci.yml
key: deps-${{ runner.os }}-${{ hashFiles('package-lock.json', 'yarn.lock') }}

Fail fast when the hash is empty

  1. Add a guard step that errors if hashFiles returns an empty string.
  2. This surfaces a missing lockfile instead of silently caching nothing.

How to prevent it

  • Confirm the lockfile path before basing a cache key on it.
  • Include runner.os and a static prefix so an empty hash is obvious.

Related guides

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