diff --git a/frontend/dockerfile/dockerfile2llb/convert.go b/frontend/dockerfile/dockerfile2llb/convert.go index 00e92b3f..cc76b2be 100644 --- a/frontend/dockerfile/dockerfile2llb/convert.go +++ b/frontend/dockerfile/dockerfile2llb/convert.go @@ -100,6 +100,9 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State, if err != nil { return nil, nil, err } + if name == "" { + return nil, nil, errors.Errorf("base name (%s) should not be blank", st.BaseName) + } st.BaseName = name ds := &dispatchState{ diff --git a/frontend/dockerfile/dockerfile2llb/convert_test.go b/frontend/dockerfile/dockerfile2llb/convert_test.go index c21c61de..ee7dc0f6 100644 --- a/frontend/dockerfile/dockerfile2llb/convert_test.go +++ b/frontend/dockerfile/dockerfile2llb/convert_test.go @@ -41,4 +41,12 @@ COPY --from=0 f2 / Target: "nosuch", }) assert.Error(t, err) + + df = `FROM "" AS foo` + _, _, err = Dockerfile2LLB(appcontext.Context(), []byte(df), ConvertOpt{}) + assert.Error(t, err) + + df = `FROM ${BLANK} AS foo` + _, _, err = Dockerfile2LLB(appcontext.Context(), []byte(df), ConvertOpt{}) + assert.Error(t, err) }