-
Notifications
You must be signed in to change notification settings - Fork 176
#394 avoiding panic when converting interfaces #395
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
Conversation
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.
I suspect you'll find similar panics happen when resolving the request/response types of an RPC method (in *MethodDescriptor.resolve
) Would you mind adding a similar fix there, too?
BTW, I suggested some tweaks to the error message. This code isn't trying to convert anything. The issue is that the descriptor is malformed: references that should be enums or messages refer to the wrong kind of element. (FWIW, protoc
will never produce malformed descriptors like this, so I'm assuming you are seeing this panics when trying to create your own descriptors or using a tool that is producing invalid descriptors.)
} | ||
enumType, ok := desc.(*EnumDescriptor) | ||
if !ok { | ||
return fmt.Errorf("could not convert desc %s to EnumDescriptor. TypeName: %s", desc, fd.proto.GetTypeName()) |
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.
return fmt.Errorf("could not convert desc %s to EnumDescriptor. TypeName: %s", desc, fd.proto.GetTypeName()) | |
return fmt.Errorf("field %v indicates a type of enum, but references %q which is %T", fd.fqn, fd.proto.GetTypeName(), desc) |
} | ||
msgType, ok := desc.(*MessageDescriptor) | ||
if !ok { | ||
return fmt.Errorf("could not convert desc %s to MessageDescriptor. TypeName: %s", desc, fd.proto.GetTypeName()) |
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.
return fmt.Errorf("could not convert desc %s to MessageDescriptor. TypeName: %s", desc, fd.proto.GetTypeName()) | |
return fmt.Errorf("field %v indicates a type of message, but references %q which is %T", fd.fqn, fd.proto.GetTypeName(), desc) |
} | ||
msgType, ok := desc.(*MessageDescriptor) | ||
if !ok { | ||
return fmt.Errorf("could not convert desc %s to MessageDescriptor. TypeName: %s", desc, fd.proto.GetTypeName()) |
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.
return fmt.Errorf("could not convert desc %s to MessageDescriptor. TypeName: %s", desc, fd.proto.GetTypeName()) | |
return fmt.Errorf("field %v extends %q which should be a message but is %T", fd.fqn, fd.proto.GetExtendee(), desc) |
Superceded by #525 |
No description provided.