build: avoid panic on linking to nil target

Note that nil targets still do not work as buildkit
does not currently support build inputs with nil values.

But this gives cleaner error from buildkit instead of
panic on the client side.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2025-11-11 11:28:53 -08:00
parent 606e9d1f48
commit 1fae6f4c2a
+6 -3
View File
@@ -1074,9 +1074,12 @@ func waitContextDeps(ctx context.Context, index int, results *waitmap.Map, so *c
for _, v := range contexts {
if len(rr.Refs) > 0 {
for platform, r := range rr.Refs {
st, err := r.ToState()
if err != nil {
return err
st := llb.Scratch()
if r != nil {
st, err = r.ToState()
if err != nil {
return err
}
}
so.FrontendInputs[k+"::"+platform] = st
so.FrontendAttrs[v+"::"+platform] = "input:" + k + "::" + platform