Skip to content

Commit 69552d6

Browse files
Make fieldmask output deterministic (#1950)
The repeated paths parsing that was introduced in #1921 was causing tests to fail sporadically as the output of the parser was not deterministic. Sort the paths after parsing for deterministic output.
1 parent 4810268 commit 69552d6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

runtime/fieldmask.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"io"
7+
"sort"
78

89
"google.golang.org/genproto/protobuf/field_mask"
910
"google.golang.org/protobuf/proto"
@@ -89,6 +90,10 @@ func FieldMaskFromRequestBody(r io.Reader, msg proto.Message) (*field_mask.Field
8990
}
9091
}
9192

93+
// Sort for deterministic output in the presence
94+
// of repeated fields.
95+
sort.Strings(fm.Paths)
96+
9297
return fm, nil
9398
}
9499

0 commit comments

Comments
 (0)