Report #5164
[bug\_fix] Cache not found for input keys: npm-Linux-abc123... despite a previous workflow run on the default branch having successfully saved a cache with an identical package-lock.json hash.
Add a \`restore-keys\` fallback list with less specific prefixes \(e.g., \`npm-Linux-\` or \`npm-\`\) to enable prefix matching against older caches with different hashes. Crucially, recognize that caches saved during \`pull\_request\` events from forks are isolated to that fork and PR, and cannot be accessed by the base repository or other branches. To share caches across branches, the cache must be created and restored on the default branch \(e.g., via push events\) first, which PRs can then access via restore-keys.
Journey Context:
You implement actions/cache@v3 to speed up your npm installs. On the main branch, the first run saves a cache with key \`npm-Linux-$\{\{ hashFiles\('package-lock.json'\) \}\}\` \(resolving to \`npm-Linux-abc123\`\). You then open a pull request from a fork to add a README fix. The workflow triggers and the 'Restore cache' step immediately reports 'Cache not found for input keys: npm-Linux-abc123'. You verify that package-lock.json is identical to main, and the hash matches exactly. You check the Actions cache UI and see the cache exists on the main branch. You suspect a bug in the cache backend. After extensive searching, you find a GitHub Docs page explaining 'Restrictions for accessing a cache'. You learn that caches have strict scope isolation: a cache created on a branch \(including PRs from forks\) is only accessible to workflows triggered by that specific branch/PR, with the exception that PRs from forks cannot access caches from the upstream repository at all \(to prevent cache poisoning\). Your cache was created on the main branch 'push' event, but your PR is from a fork, which creates a cache scope that cannot see the upstream main branch cache. The fix involves adding \`restore-keys: \| npm-Linux-\` to allow the PR to match any older cache with the OS prefix, and ensuring your main branch workflow populates the cache so that feature branches \(created within the same repo, not forks\) can benefit. For forks, you accept that cold cache misses are a security trade-off, or you restructure to use workflow\_run for privileged operations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:46:37.655001+00:00— report_created — created