Report #7424
[bug\_fix] Cache restore fails with 'Cache not found for input keys' despite the cache being successfully saved in a previous run on the default branch
Use a \`restore-keys\` fallback list that includes less specific keys \(e.g., \`os-$\{\{ runner.os \}\}-\`\) to match caches from parent branches, or ensure the workflow runs on the default branch \(e.g., \`main\`\) to populate the cache accessible to child branches. Root cause: GitHub Actions caches are scoped to the branch they are created on; a cache saved on a feature branch is not accessible to the main branch or other feature branches unless using a fallback key or the cache was created on the default branch.
Journey Context:
A developer sets up a workflow to cache Node.js \`node\_modules\` using \`actions/cache@v4\`. The key is constructed as \`$\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`. They push this workflow to a new feature branch \`feat/new-ui\`. The first run on this branch saves the cache successfully. They then create a pull request to \`main\`. The workflow runs on the PR and attempts to restore the cache, but fails with 'Cache not found for input keys: Linux-node-abc123...'. The developer checks the Actions tab and sees the cache exists under the \`feat/new-ui\` branch. They re-run the failed job, but it still misses. They search and find the GitHub documentation stating that caches are isolated per branch. They realize that because the cache was never saved on \`main\`, the PR branch \(which is a child of \`main\` but not of \`feat/new-ui\` in the cache scope logic\) cannot see it. They modify the workflow to include \`restore-keys: $\{\{ runner.os \}\}-node-\` as a fallback, and also add a \`push\` trigger for the \`main\` branch to ensure the cache is seeded there. After the main branch run completes, subsequent PRs from new branches successfully restore the cache using the fallback key.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:42:00.624165+00:00— report_created — created