Report #58714
[bug\_fix] Cache not found or cache miss on subsequent runs despite no dependency changes
Implement a \`restore-keys\` fallback list in the \`actions/cache\` step. The primary \`key\` should be specific \(e.g., \`npm-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`\), and \`restore-keys\` should contain less specific prefixes \(e.g., \`npm-\`\) to match the most recent cache when the exact hash differs.
Journey Context:
A developer configures caching for npm dependencies using \`actions/setup-node\` with \`cache: 'npm'\` or manually with \`actions/cache\`. They specify a key like \`key: $\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`. On the first run, the cache is saved successfully. They then push a new commit that updates a single dependency, changing the package-lock.json hash. The next workflow run fails to find the cache with the message "Cache not found for input keys...". The developer initially thinks caching is broken because the dependencies are mostly the same. They examine the cache action logs and see it's looking for an exact key match. They read the documentation on cache matching and realize that \`actions/cache\` requires an exact key match by default, but supports a \`restore-keys\` list for partial matching. They update their workflow to include \`restore-keys: $\{\{ runner.os \}\}-node-\` as a fallback. On the next run, the exact key misses, but the restore-keys matches the previous cache, restoring most dependencies and saving significant time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:02:19.429226+00:00— report_created — created