Skip to content
Latchkey

GitHub Actions "Cache upload failed ... 400" - Failed Cache Save

Saving a cache failed when the cache service responded with 400. This is usually a transient upload issue (or a duplicate/oversized entry); the job still succeeds because the cache save is best-effort.

What this error means

An actions/cache save (post step) logs "Cache upload failed because the cache service responded with 400". The job result is unaffected - only the cache was not stored this run.

Actions log
Warning: Failed to save: Cache upload failed because the cache service
responded with 400.

Common causes

Transient upload failure

A brief backend hiccup during the multi-part cache upload returns 400. The next run typically saves the cache cleanly.

Duplicate key or oversized entry

Trying to save a key that already exists, or an entry too large for the cache, can be rejected - the cache is immutable per key.

How to fix it

Let the save be best-effort

A failed save does not fail the job. Ensure nothing depends on the save succeeding within the same run.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.gradle/caches
    key: gradle-${{ hashFiles('**/*.gradle*') }}
# a 400 on the post-save step only warns; the build still passes

Avoid duplicate/oversized saves

  1. Make the key reflect content so you are not re-saving an identical existing key.
  2. Reduce cache size by excluding large, regenerable files from the cached path.
  3. Re-run if the 400 was a one-off upload blip.

How to prevent it

  • Key caches on content so saves are not redundant.
  • Keep cached paths lean to avoid oversized entries.
  • Never make a run depend on its own cache save succeeding.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →