Skip to content

Commit

Permalink
fix: update to protobuf 1.36.0 and exclude synthetic oneofs during po…
Browse files Browse the repository at this point in the history
…pulateFieldValueFromPath (#5072)
  • Loading branch information
aerialls authored Dec 19, 2024
1 parent 50d84d5 commit e062b12
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 217 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576
google.golang.org/grpc v1.69.2
google.golang.org/protobuf v1.35.2
google.golang.org/protobuf v1.36.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 h1:
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU=
google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=
google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
4 changes: 2 additions & 2 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1882,8 +1882,8 @@ def go_repositories():
go_repository(
name = "org_golang_google_protobuf",
importpath = "google.golang.org/protobuf",
sum = "h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=",
version = "v1.35.2",
sum = "h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=",
version = "v1.36.0",
)
go_repository(
name = "org_golang_x_crypto",
Expand Down
430 changes: 221 additions & 209 deletions runtime/internal/examplepb/proto3.pb.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion runtime/internal/examplepb/proto3.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "google/protobuf/wrappers.proto";
option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb";

message Proto3Message {
// Next number: 49
// Next number: 50
Proto3Message nested = 41;
float float_value = 42;
double double_value = 43;
Expand All @@ -23,6 +23,7 @@ message Proto3Message {
string string_value = 8;
bytes bytes_value = 9;
repeated string repeated_value = 10;
optional string optional_value = 49;
repeated google.protobuf.UInt64Value repeated_message = 44;
EnumValue enum_value = 11;
repeated EnumValue repeated_enum = 12;
Expand Down
2 changes: 1 addition & 1 deletion runtime/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func populateFieldValueFromPath(msgValue protoreflect.Message, fieldPath []strin
}

// Check if oneof already set
if of := fieldDescriptor.ContainingOneof(); of != nil {
if of := fieldDescriptor.ContainingOneof(); of != nil && !of.IsSynthetic() {
if f := msgValue.WhichOneof(of); f != nil {
return fmt.Errorf("field already set for oneof %q", of.FullName().Name())
}
Expand Down
5 changes: 4 additions & 1 deletion runtime/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func TestPopulateParameters(t *testing.T) {
durationStr := durationT.String()
durationPb := durationpb.New(durationT)

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

Expand Down Expand Up @@ -134,6 +135,7 @@ func TestPopulateParameters(t *testing.T) {
"string_value": {"str"},
"bytes_value": {"YWJjMTIzIT8kKiYoKSctPUB-"},
"repeated_value": {"a", "b", "c"},
"optional_value": {optionalStr},
"repeated_message": {"1", "2", "3"},
"enum_value": {"1"},
"repeated_enum": {"1", "2", "0"},
Expand Down Expand Up @@ -184,6 +186,7 @@ func TestPopulateParameters(t *testing.T) {
StringValue: "str",
BytesValue: []byte("abc123!?$*&()'-=@~"),
RepeatedValue: []string{"a", "b", "c"},
OptionalValue: &optionalStr,
RepeatedMessage: []*wrapperspb.UInt64Value{{Value: 1}, {Value: 2}, {Value: 3}},
EnumValue: examplepb.EnumValue_Y,
RepeatedEnum: []examplepb.EnumValue{examplepb.EnumValue_Y, examplepb.EnumValue_Z, examplepb.EnumValue_X},
Expand Down Expand Up @@ -499,7 +502,7 @@ func TestPopulateParameters(t *testing.T) {
values: url.Values{
"timestampValue": {"0000-01-01T00:00:00.00Z"},
},
filter: utilities.NewDoubleArray(nil),
filter: utilities.NewDoubleArray(nil),
want: &examplepb.Proto3Message{},
wanterr: errors.New(`parsing field "timestamp_value": 0000-01-01T00:00:00.00Z before 0001-01-01`),
},
Expand Down

0 comments on commit e062b12

Please sign in to comment.