actions / actions/cache

Misleading error message when attempting to overwrite the existing cache

Open
#1,665 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

The caching step in my GHA workflow is defined as follows:

    - name: Restore setup cache
      id: cache-setup
      uses: actions/cache@v4
      with:
        key: SingleAction-ospsuite-${{ env.TOOLS_CSV_HASH }}
        path: |
          ${{ env.R_LIBS_USER }}

For some reason, the action cannot find an existing cache, but that's a different issue that I'm investigating.

As the cache could not be found, the action attempts to save it again in the Post-restore setup cache step, which results in the error message.
Failed to save: Unable to reserve cache with key SingleAction-ospsuite-f063a3bc68c3b4305b4e8672a9616eeab746134e3af41c4a95b6f14b6bd85cf6, another job may be creating this cache.

I struggled with this error message for a while — there were no parallel jobs that could lock the cache or anything like that.
After enabling action debugging, the last debug message before this error appeared was:
##[debug]Failed to reserve cache: Error: Failed to CreateCacheEntry: Received non-retryable error: Failed request: (409) Conflict: cache entry with the same key, version, and scope already exists

This makes perfect sense and should be displayed as an error message.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the actions/cache@v4 save path used by the Post-restore setup cache step and compare the surfaced message with the debug output showing a 409 conflict. The work is done when an existing cache with the same key, version, and scope reports that condition instead of implying another job is creating it.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.