Skip to content
Latchkey

GitHub Actions cache fail-on-cache-miss Aborting the Job

A restore step with fail-on-cache-miss: true aborts the job whenever no cache entry exists for the key - intended for jobs that require a prior save, but a surprise on the first run or after a key change.

What this error means

A job that worked before now fails at the restore step with a cache-miss error, typically right after a dependency change rotated the key or on a brand-new branch.

Actions log
Error: Failed to restore cache entry. Unable to find a cache entry for the
specified key, and fail-on-cache-miss is set.

Common causes

No entry yet for the current key

fail-on-cache-miss is meant for jobs that consume a cache produced by an earlier job. The very first run, or a run after the key changed, has nothing to restore and hard-fails.

Restore key rotated by a dependency change

A hashFiles-based key changes when the lockfile changes, so the new key has no saved entry until a save runs, and a strict restore fails meanwhile.

How to fix it

Only fail-fast when a prior save is guaranteed

Use fail-on-cache-miss in a consumer job that always runs after a producer job that saved the exact key.

.github/workflows/ci.yml
# producer job saves build-${{ github.sha }}
# consumer job:
- uses: actions/cache/restore@v4
  with:
    path: dist
    key: build-${{ github.sha }}
    fail-on-cache-miss: true

Allow a soft miss for self-populating caches

  1. Drop fail-on-cache-miss for dependency caches that populate themselves on a miss.
  2. Add restore-keys so a near-miss still restores a useful prefix.
  3. Reserve the strict flag for required hand-offs between jobs.

How to prevent it

  • Use fail-on-cache-miss only for required producer/consumer hand-offs.
  • Let self-populating caches miss softly and rebuild.
  • Provide restore-keys for graceful prefix fallback.

Related guides

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