Report #44746
[bug\_fix] Cache not found despite previous successful run saving cache with identical appearing key pattern
Add \`restore-keys\` with a prefix match \(e.g., \`$\{\{ runner.os \}\}-node-\`\) to the \`actions/cache\` step. Root cause: Cache keys are immutable and require an exact string match; if the lockfile hash changes even slightly \(e.g., a patch version update\), the exact key misses. \`restore-keys\` enables prefix matching to retrieve the most recent similar cache, allowing partial cache hits rather than total misses.
Journey Context:
You have a Node.js project and configure \`actions/cache\` with \`key: $\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`. The first run on \`main\` saves a cache successfully. You push a commit that updates a single dependency, changing the \`package-lock.json\` hash. The next run logs 'Cache not found for input keys: ...' and proceeds to run \`npm ci\` slowly. You panic, thinking the cache service is down. You check the Actions tab under 'Caches' and see the previous cache is still there. You realize the hash changed. You search 'github actions cache not found different key' and find an issue explaining that \`restore-keys\` is required for partial matching. You add \`restore-keys: $\{\{ runner.os \}\}-node-\` and suddenly the cache restores instantly on partial matches, falling back to older dependencies when lockfiles change, dramatically speeding up builds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:34:22.418254+00:00— report_created — created