Report #15843
[bug\_fix] Cache not found for input keys despite cache existing on main branch
Add restore-keys with a prefix fallback \(e.g., 'npm-Linux-'\) to match partial keys from the default branch
Journey Context:
Developer implements dependency caching using actions/cache to speed up npm install. The workflow runs on the main branch and successfully saves a cache with key 'npm-Linux-$\{\{ hashFiles\('package-lock.json'\) \}\}'. When a developer creates a feature branch and opens a pull request, the workflow runs but reports 'Cache not found for input keys'. The developer verifies the cache exists in the Actions tab under Cache management. After reading the GitHub documentation, they learn that caches are scoped to the branch and event type \(push vs pull\_request\) for security and isolation. The solution is to add a restore-keys list with a less specific prefix \(e.g., 'npm-Linux-'\) which allows the cache action to fall back to the most recent cache from the default branch when an exact match isn't found on the feature branch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:14:25.178722+00:00— report_created — created