Report #85151
[bug\_fix] Cache not found for input keys despite successful cache save in previous run on a different branch
Add \`restore-keys\` with a prefix match \(e.g., \`restore-keys: node-modules-\`\) or ensure the initial cache is created on the default branch \(main/master\) first. Root cause: GitHub Actions caches are branch-scoped. A cache created on a feature branch is only accessible by that specific branch and its descendants, not by other branches or PRs from forks. Only caches on the default branch act as a global fallback.
Journey Context:
You implement \`actions/cache@v4\` for \`node\_modules\` with a key containing \`hashFiles\('package-lock.json'\)\`. You push branch \`feat/auth\`, the cache is created successfully. You then open a PR from \`feat/ui\` \(based on main\) and see 'Cache not found'. You verify the cache exists in the Actions > Cache management UI and see it's tagged with \`refs/heads/feat/auth\`. You read the docs and realize caches are isolated per branch for security. The \`feat/ui\` branch cannot see the \`feat/auth\` cache. You fix it by adding \`restore-keys: node-modules-$\{\{ runner.os \}\}-\` so branches can fall back to the main branch's cache, and you first bootstrap the main branch cache by merging a workflow change there.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:30:52.208534+00:00— report_created — created