Skip to content

Commit e062b12

Browse files
authored
fix: update to protobuf 1.36.0 and exclude synthetic oneofs during populateFieldValueFromPath (#5072)
1 parent 50d84d5 commit e062b12

File tree

7 files changed

+233
-217
lines changed

7 files changed

+233
-217
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576
1212
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576
1313
google.golang.org/grpc v1.69.2
14-
google.golang.org/protobuf v1.35.2
14+
google.golang.org/protobuf v1.36.0
1515
gopkg.in/yaml.v3 v3.0.1
1616
)
1717

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 h1:
4747
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
4848
google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU=
4949
google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
50-
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
51-
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
50+
google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=
51+
google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
5252
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
5353
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
5454
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

repositories.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,8 +1882,8 @@ def go_repositories():
18821882
go_repository(
18831883
name = "org_golang_google_protobuf",
18841884
importpath = "google.golang.org/protobuf",
1885-
sum = "h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=",
1886-
version = "v1.35.2",
1885+
sum = "h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=",
1886+
version = "v1.36.0",
18871887
)
18881888
go_repository(
18891889
name = "org_golang_x_crypto",

runtime/internal/examplepb/proto3.pb.go

Lines changed: 221 additions & 209 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/internal/examplepb/proto3.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import "google/protobuf/wrappers.proto";
1111
option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb";
1212

1313
message Proto3Message {
14-
// Next number: 49
14+
// Next number: 50
1515
Proto3Message nested = 41;
1616
float float_value = 42;
1717
double double_value = 43;
@@ -23,6 +23,7 @@ message Proto3Message {
2323
string string_value = 8;
2424
bytes bytes_value = 9;
2525
repeated string repeated_value = 10;
26+
optional string optional_value = 49;
2627
repeated google.protobuf.UInt64Value repeated_message = 44;
2728
EnumValue enum_value = 11;
2829
repeated EnumValue repeated_enum = 12;

runtime/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func populateFieldValueFromPath(msgValue protoreflect.Message, fieldPath []strin
141141
}
142142

143143
// Check if oneof already set
144-
if of := fieldDescriptor.ContainingOneof(); of != nil {
144+
if of := fieldDescriptor.ContainingOneof(); of != nil && !of.IsSynthetic() {
145145
if f := msgValue.WhichOneof(of); f != nil {
146146
return fmt.Errorf("field already set for oneof %q", of.FullName().Name())
147147
}

runtime/query_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func TestPopulateParameters(t *testing.T) {
9494
durationStr := durationT.String()
9595
durationPb := durationpb.New(durationT)
9696

97+
optionalStr := "str"
9798
fieldmaskStr := "float_value,double_value"
9899
fieldmaskPb := &field_mask.FieldMask{Paths: []string{"float_value", "double_value"}}
99100

@@ -134,6 +135,7 @@ func TestPopulateParameters(t *testing.T) {
134135
"string_value": {"str"},
135136
"bytes_value": {"YWJjMTIzIT8kKiYoKSctPUB-"},
136137
"repeated_value": {"a", "b", "c"},
138+
"optional_value": {optionalStr},
137139
"repeated_message": {"1", "2", "3"},
138140
"enum_value": {"1"},
139141
"repeated_enum": {"1", "2", "0"},
@@ -184,6 +186,7 @@ func TestPopulateParameters(t *testing.T) {
184186
StringValue: "str",
185187
BytesValue: []byte("abc123!?$*&()'-=@~"),
186188
RepeatedValue: []string{"a", "b", "c"},
189+
OptionalValue: &optionalStr,
187190
RepeatedMessage: []*wrapperspb.UInt64Value{{Value: 1}, {Value: 2}, {Value: 3}},
188191
EnumValue: examplepb.EnumValue_Y,
189192
RepeatedEnum: []examplepb.EnumValue{examplepb.EnumValue_Y, examplepb.EnumValue_Z, examplepb.EnumValue_X},
@@ -499,7 +502,7 @@ func TestPopulateParameters(t *testing.T) {
499502
values: url.Values{
500503
"timestampValue": {"0000-01-01T00:00:00.00Z"},
501504
},
502-
filter: utilities.NewDoubleArray(nil),
505+
filter: utilities.NewDoubleArray(nil),
503506
want: &examplepb.Proto3Message{},
504507
wanterr: errors.New(`parsing field "timestamp_value": 0000-01-01T00:00:00.00Z before 0001-01-01`),
505508
},

0 commit comments

Comments
 (0)