Report #93424
[bug\_fix] Cache not found for input keys in actions/cache even when cache was saved in previous runs
Ensure the cache \`key\` is deterministic and identical between save and restore operations. Do not use \`$\{\{ github.sha \}\}\` or timestamps in the primary key if you need cache hits across runs. Use \`restore-keys\` with partial prefixes \(e.g., \`os-runner-npm-\`\) to match previous caches when exact key misses. The root cause is that cache keys must match exactly, and dynamic content like git SHAs create unique keys every run.
Journey Context:
Developer configures caching for Node.js dependencies using \`actions/cache@v4\`. They set \`key: $\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}-$\{\{ github.sha \}\}\` believing more specificity prevents collisions. The post-job cache save succeeds. In a subsequent workflow run \(even on the same commit\), the cache restore step reports "Cache not found for input keys". The developer checks the cache list in GitHub UI and sees the cache exists with the exact SHA from the previous run, but realizes the new run has a different SHA \(new commit\). They remove \`$\{\{ github.sha \}\}\` from the key, keeping only \`$\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`, and add \`restore-keys: \| $\{\{ runner.os \}\}-node-\` to allow partial matches when package-lock changes slightly. The cache now hits consistently across commits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:24:02.130118+00:00— report_created — created