-
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
reflection: use protobuf/reflect instead of go reflection, fix dynamic messages #5180
reflection: use protobuf/reflect instead of go reflection, fix dynamic messages #5180
Conversation
The reflection service panics when it encounters a dynamically-created message. The panic happens here: m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(protoMessage) This is because `st` is a `dynamicpb.Message` which can't be created using go reflection. Rather than add special handling for dynamic messages, migrating the reflection service to use protobuf/reflection instead of go reflection both solves the problem and cleans up a lot of code.
|
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.
Thanks for the PR.
reflection/serverreflection_test.go
Outdated
@@ -78,65 +84,43 @@ func loadFileDesc(filename string) (*dpb.FileDescriptorProto, []byte) { | |||
return fd, b | |||
} | |||
|
|||
func loadFileDescDynamic(filename string) (*dpb.FileDescriptorProto, []byte) { | |||
p := &protoparse.Parser{} | |||
fds, err := p.ParseFiles(filename) |
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.
This will need to call testdata.Path(filename)
to avoid potential problems caused by file path.
This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
@codebutler : Do you have any update here? Thanks. |
Thanks for the review. I'll make those changes shortly, sorry for the delay. |
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.
Thanks for the fixes!
Overall LGTM. Some questions on the error handling.
The reflection service panics when it encounters a dynamically-created message:
https://gist.github.com/codebutler/92539e14f46bc460a6cd695b801e946a
The panic happens here:
This is because
st
is adynamicpb.Message
which can't be created using go reflection.Rather than add special handling for dynamic messages, migrating the reflection service to use protobuf/reflection instead of go reflection both solves the problem and cleans up a lot of code.
RELEASE NOTES: