Skip to content
Latchkey

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.

buildx
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

  1. Give each image its own scope so builds do not overwrite each other.
  2. Drop mode=max to the default mode=min if the 400 persists.
  3. Re-run; the export is best-effort and the image build is unaffected.
.github/workflows/ci.yml
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.

Frequently asked questions

What causes ""failed to parse error response ... 400""?
A partial GitHub outage or a slow cache service returns a 400 (often an HTML error page) that BuildKit cannot parse.
How do I fix "failed to parse error response ... 400"?
Scope the cache and lower the export mode

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card