Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update to protobuf 1.36.0 and exclude synthetic oneofs during populateFieldValueFromPath #5072

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading