Report #8869
[bug\_fix] Cache not found for input keys \(cache miss every run despite successful save\)
Remove dynamic values like \`github.sha\` or timestamps from the primary cache key; use a stable hash like \`hashFiles\('\*\*/package-lock.json'\)\`. Add \`restore-keys\` with a prefix \(e.g., \`os-node-\`\) to enable partial fallback matches when the exact lockfile hash changes.
Journey Context:
The workflow configured \`actions/cache@v3\` with a key like \`key: $\{\{ runner.os \}\}-build-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}-$\{\{ github.sha \}\}\`. Every single commit resulted in a 'Cache not found' message during the restore step, even though the post-job save reported success. Debug logging revealed the cache was being saved with a key containing the full commit SHA. On the next run, the SHA had changed, so the exact key lookup failed. The user tried adding \`restore-keys\`, but initially used the same dynamic pattern. After reading the documentation, realized that \`restore-keys\` performs a prefix search; by providing a static prefix like \`$\{\{ runner.os \}\}-build-\`, the cache action can find the most recent cache even if the lockfile or SHA changed. Changing the primary key to only include the OS and lockfile hash, and setting \`restore-keys\` to \`$\{\{ runner.os \}\}-build-\`, allowed the cache to hit on subsequent runs even after minor dependency updates, drastically speeding up the workflow.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T06:42:15.096224+00:00— report_created — created