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.
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.
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: gradle-${{ hashFiles('**/*.gradle*') }}
# a 400 on the post-save step only warns; the build still passesAvoid duplicate/oversized saves
- Make the key reflect content so you are not re-saving an identical existing key.
- Reduce cache size by excluding large, regenerable files from the cached path.
- 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.