buildx GitHub Actions cache export "failed to parse error response: ... 400" in CI
BuildKit tried to export build cache to the GitHub Actions cache service and got an HTTP 400 it could not parse. This is usually a cache service hiccup, a missing scope, or a mode=max export the backend rejected, not a Dockerfile problem.
What this error means
A build with --cache-to type=gha fails or warns with "failed to solve: ... failed to parse error response: response status code 400" while the image itself built fine.
ERROR: failed to solve: error writing layer blob: failed to parse error response:
response status code 400: <html>...</html>Common causes
A transient GitHub Actions cache service error
A partial GitHub outage or a slow cache service returns a 400 (often an HTML error page) that BuildKit cannot parse.
mode=max export overruns the cache backend
Exporting every intermediate layer with mode=max can trip a 400 on large builds; a scoped or mode=min export avoids it.
How to fix it
Scope the cache and lower the export mode
- Give each image its own
scopeso builds do not overwrite each other. - Drop
mode=maxto the defaultmode=minif the 400 persists. - Re-run; the export is best-effort and the image build is unaffected.
cache-to: type=gha,mode=min,scope=${{ github.workflow }}
cache-from: type=gha,scope=${{ github.workflow }}Do not fail the build on cache export errors
Cache export is best-effort. A transient 400 should not break the pipeline; retry the job and the cache repopulates.
How to prevent it
- Scope gha cache per image to avoid overwrites.
- Prefer mode=min unless you need full intermediate caching.
- Treat cache export 400s as transient and retry.