-
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
encoding/proto: do not panic when types do not match #4218
Conversation
encoding/proto/proto.go
Outdated
return proto.Marshal(v.(proto.Message)) | ||
vv, ok := v.(proto.Message) | ||
if !ok { | ||
return nil, fmt.Errorf("failed to marshal, message is %T, want proto", v) |
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.
nit: proto.Message
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.
Done
encoding/proto/proto.go
Outdated
return proto.Unmarshal(data, v.(proto.Message)) | ||
vv, ok := v.(proto.Message) | ||
if !ok { | ||
return fmt.Errorf("failed to marshal, message is %T, want proto", v) |
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.
"unmarshal", proto.Message
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.
Done
2a66eac
to
f161aa5
Compare
fixes #4213
The type mismatch can happen if
proto.Message
application/grpc+subtype
)