If the target path doesn't match the source path, restore reports "Cache not found for input keys"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.6k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
Hey there,
I've been trying to use the save/restore actions from two separate jobs, and after six hours of head-scratching, worked out what's going on. If the path provided to the restore command doesn't exactly match the path that was provided to the save command, the restore action reports "Cache not found for input keys". Here's a repro case. Run this in any repo, then look at the action console output; the second fetch-stuff-from-cache job won't restore any files.
name: cache-test
on:
push:
branches: ["main"]
paths:
- '.github/workflows/caching-test.yml'
workflow_dispatch:
jobs:
cache-some-stuff:
runs-on: ubuntu-latest
steps:
- name: Create some files
run: |
mkdir my-files
echo "Hello" > my-files/file0001.txt
echo "World" > my-files/file0002.txt
ls -lR
- uses: actions/cache/save@v4
id: put-files-in-cache
with:
path: my-files
key: my-cached-files-${{ github.run_id }}
fetch-stuff-from-cache-success:
runs-on: ubuntu-latest
steps:
- name: restore files from from cache
uses: actions/cache/restore@v4
with:
path: my-files
key: my-cached-files
- name: List files
run: ls -lR
fetch-stuff-from-cache-failure:
runs-on: ubuntu-latest
steps:
- name: restore files from from cache
uses: actions/cache/restore@v4
with:
path: this-will-fail-because-the-path-is-not-the-same
key: my-cached-files
- name: List files
run: ls -lR
It's not clear anywhere in the documentation or in the error message that you can only restore cached content to the same path it was originally cached from - presumably because if you're using the cache action rather than separate save/restore actions there's no way to specify a different path.
Is there any underlying technical reason I can't restore cached content to a different path than it was originally saved from? If not, this would make the save/restore combination far more flexible for caching files in complex build jobs - but if this isn't possible, could the restore error message be updated to make it explicit that the target path doesn't match and that's the reason it can't find anything?
Thanks,
Dylan
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the workflow using actions/cache/save@v4 and actions/cache/restore@v4, comparing the successful and failing path values. Then inspect the save and restore action entry points for how cache keys and paths are handled. Done means establishing whether different restore paths are supported and, if not, making the failure explanation explicit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, typescript
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100