Report #54314
[bug\_fix] Cache not found for input keys: npm-... \(cache miss on every run despite lockfile not changing\)
Use \`hashFiles\('\*\*/package-lock.json'\)\` \(or yarn.lock, Cargo.lock, etc.\) as part of the cache key, and provide a \`restore-keys\` fallback prefix \(e.g., \`npm-\`\) to enable partial matching. Avoid dynamic keys like \`$\{\{ github.run\_id \}\}\` or \`$\{\{ github.sha \}\}\` which change every run.
Journey Context:
A developer adds \`actions/cache\` to speed up npm installs. They initially set the key to \`npm-$\{\{ github.run\_id \}\}\` thinking a unique ID helps. The first run saves the cache. The second run uses a new \`run\_id\`, looks for a key that doesn't exist, and gets a cache miss, re-downloading everything. The developer then switches to \`npm-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`. Now the key only changes when dependencies change. They also add \`restore-keys: \| npm-\` as a fallback. On the next run with a modified lockfile, it fails to find the exact hash, but \`restore-keys\` matches the \`npm-\` prefix and restores the previous cache layer, allowing the cache to update efficiently rather than starting from zero.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:39:48.223260+00:00— report_created — created