From 9f83b182afc3a8163e04dbfc638723a848cda8f5 Mon Sep 17 00:00:00 2001 From: Kazuyoshi Kato Date: Tue, 21 Nov 2023 02:50:04 -0800 Subject: [PATCH] Treat an empty message as nil In google.golang.org/protobuf, an empty message and nil are interchangeable. https://github.com/golang/protobuf/issues/965 Signed-off-by: Kazuyoshi Kato --- client/llb/definition.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/llb/definition.go b/client/llb/definition.go index 14486dc088535..cdd320897cc5f 100644 --- a/client/llb/definition.go +++ b/client/llb/definition.go @@ -29,9 +29,11 @@ type DefinitionOp struct { inputCache *sync.Map // shared and written among DefinitionOps so avoid race on this map using sync.Map } +var empty = &pb.Definition{} + // NewDefinitionOp returns a new operation from a marshalled definition. func NewDefinitionOp(def *pb.Definition) (*DefinitionOp, error) { - if def == nil { + if def == nil || proto.Equal(def, empty) { return nil, errors.New("invalid nil input definition to definition op") }