Report #88866
[bug\_fix] Cache not found for input keys despite successful cache save in previous run
Add \`restore-keys\` with a prefix \(e.g., \`node-cache-Linux-\`\) to enable partial matching, or understand that caches saved on feature branches are isolated and not visible to the default branch or other branches. Root cause: GitHub Actions cache entries are immutable and scoped to the branch they are saved on, with the exception that caches from the default branch \(usually \`main\`\) can be accessed by feature branches; feature branch caches are never accessible to other branches or PRs from forks.
Journey Context:
A developer configures a workflow using \`actions/setup-node\` with \`cache: 'npm'\`. On the first push to \`main\`, the post-action step saves a cache with the key \`node-cache-Linux-npm-abc123\`. The developer then creates a feature branch \`feature/x\` and opens a Pull Request. The workflow runs on the \`pull\_request\` event, but the "Set up job" step logs "Cache not found for input keys: node-cache-Linux-npm-xyz789". The developer checks the Actions cache management page and sees the \`main\` branch cache is still there. Suspecting a hash mismatch in \`package-lock.json\`, the developer downloads both lock files and compares them—they are identical. The developer then tries manually copying the exact cache key from the main branch run into the feature branch workflow, but it still reports not found. After hours of debugging, the developer finds a GitHub Community post titled "Cache not found in PR but exists on main". The documentation linked there explains the scoping rule: feature branches cannot see each other's caches, only the default branch's cache. The developer realizes they need to add a \`restore-keys\` fallback to \`node-cache-Linux-\` so that the feature branch can at least restore the \`main\` branch cache as a base, even if the exact lock hash differs. Alternatively, they accept that the first commit on a new branch will always rebuild the cache.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:45:00.925373+00:00— report_created — created