Report #39354
[bug\_fix] COPY failed: cache key not found \(during multi-stage build\)
Ensure the source path being copied from the previous build stage actually exists. If the previous stage's build step failed silently or outputted to a different directory, correct the path in the COPY --from instruction.
Journey Context:
A developer is using a multi-stage build. Stage 1 compiles code to \`/app/dist\`, and Stage 2 uses \`COPY --from=builder /app/dist /app/dist\`. The build fails with \`cache key not found\`. The developer is deeply confused because they expect a 'file not found' or 'directory not found' error, not a cache error. They search the BuildKit source code and issues, discovering that BuildKit resolves COPY sources as cache keys. If the source artifact doesn't exist in the intermediate image, the cache key computation fails entirely, resulting in this cryptic error instead of a standard filesystem error. They inspect Stage 1, realize their build script actually outputted to \`/app/build\` instead of \`/app/dist\`, update the COPY instruction to match the real path, and the build succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:31:39.335098+00:00— report_created — created