-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
status: Fix status incompatibility introduced by #6919 and move non-regeneratable proto code into /testdata #7724
base: master
Are you sure you want to change the base?
Conversation
c313346
to
3b088a0
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7724 +/- ##
==========================================
- Coverage 81.77% 81.57% -0.21%
==========================================
Files 361 364 +3
Lines 27826 28304 +478
==========================================
+ Hits 22756 23088 +332
- Misses 3865 4023 +158
+ Partials 1205 1193 -12
|
} | ||
|
||
if diff := cmp.Diff(details, gotDetails, protocmp.Transform()); diff != "" { | ||
t.Errorf("(%v).Details got unexpected output, diff (-got +want):\n%s", s, diff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order in the output, (-got +want)
, needs to be swapped I guess based on the order of parameters passed to cmp.Diff
.
details := []protoadapt.MessageV1{ | ||
&tpb.SimpleMessage{ | ||
Data: "abc", | ||
}, | ||
&testpb.Empty{}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit (optional)
I feel this is more readable and compact:
details := []protoadapt.MessageV1{
&tpb.SimpleMessage{Data: "abc"},
&testpb.Empty{},
}
@@ -0,0 +1,27 @@ | |||
/* | |||
* Copyright 2022 gRPC authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be 2024
?
Fixes: #7679
Problem
#6919 migrated usages of
github.com/golang/protobuf
togoogle.golang.org/protobuf/proto
withinstatus
package. Prior to this, status.Details() calledptypes.UnmarshalAny
which calledproto.MessageV1(mt.New().Interface())
which calledprotoimpl.X.ProtoMessageV1Of(m)
so the returned type always implementedprotoadapt.MessageV1
and was always the same type given to status.WithDetails(). After the change,Status.Details()
usedanpb.Any.UnmarshallNew()
which returns the vanilla type used while creating theanypb.Any
which is only guaranteed to implement theMessageV2
API.Effect
Users of code generated from
protoc-gen-go
< v1.4 (launched in 2020) would get a wrapped MessageV2 when callingStatus.Details()
even though they would have provided a type that only implementedMessageV1
toStatus.WithDetails()
.Fix
This PR brings back the call to
protoimpl.X.ProtoMessageV1Of(m)
by callingprotoadapt.MessageV1Of
before returning the Detail messages. A test is also added to catch regressions. Since the test uses generated code fromprotoc-gen-go
v1.3, a dependency ongithub.com/golang/protobuf
is re-introduced ingo.mod
.Additional Changes
This PR also moves the generated code that is used for testing and must not be re-generated from the
reflections/test
module into a common directory under the parentgrpc
module.RELEASE NOTES: