You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means users can get into a situation where they mix descriptors of different sources (e.g. global proto registry vs. a custom registry) in the same message hierarchy, which ultimately means the protoreflect package will panic when calling e.g. Has.
Here’s a demo CL which contains a failing test for this issue, to illustrate: https://go.dev/cl/601255
It’s not entirely clear to us whether we can make the validation stricter without risking breakage. If anyone has any information one way or the other, please let us know.
Currently, when using the protoreflect package, the descriptors have to be pointer-identical: https://github.com/protocolbuffers/protobuf-go/blob/219bda23ffda544ed4cc5d5a75d34ce3b100ce51/internal/impl/message_reflect.go#L438-L443
However, the dynamicpb package is less strict and allows setting a message with a non-identical descriptor, as long as the descriptor name matches: https://github.com/protocolbuffers/protobuf-go/blob/219bda23ffda544ed4cc5d5a75d34ce3b100ce51/types/dynamicpb/dynamic.go#L589-L591
This means users can get into a situation where they mix descriptors of different sources (e.g. global proto registry vs. a custom registry) in the same message hierarchy, which ultimately means the protoreflect package will panic when calling e.g.
Has
.Here’s a demo CL which contains a failing test for this issue, to illustrate: https://go.dev/cl/601255
Here’s a CL which adds validation to prevent this issue: https://go.dev/cl/500315
It’s not entirely clear to us whether we can make the validation stricter without risking breakage. If anyone has any information one way or the other, please let us know.
If we can’t make a decision on this, we could change the behavior, but also introduce an escape hatch like we have in the protoregistry package: https://github.com/protocolbuffers/protobuf-go/blob/219bda23ffda544ed4cc5d5a75d34ce3b100ce51/reflect/protoregistry/registry.go#L30-L65
The text was updated successfully, but these errors were encountered: