Skip to content

Commit

Permalink
Treat an empty message as nil
Browse files Browse the repository at this point in the history
In google.golang.org/protobuf, an empty message and nil are interchangeable.

golang/protobuf#965

Signed-off-by: Kazuyoshi Kato <[email protected]>
  • Loading branch information
kzys committed Nov 21, 2023
1 parent d50b3b1 commit 9f83b18
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/llb/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit 9f83b18

Please sign in to comment.