-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more thorough checks for when to adapt a value when resolving cus…
…tom feature (#306) Previously, the protoutil.ResolveCustomFeature code was unable to reliably handle the following case: 1. The descriptor includes dynamic extensions for all custom options and custom features. 2. The user supplies a _generated_ extension type, to query for the custom feature. The code here _ostensibly_ handles this. But the cases where it decides it needs to adapt the value (by marshalling and then unmarshalling into different type) isn't quite thorough enough. The issue is when the custom feature is a _message_. In that case, it works fine to query for the extension itself. But if we then need to extract a field from the message, the field descriptor is likely referring to a generated message type, whose descriptor is an instance in `protoregistry.GlobalTypes`. But the value is likely to be a dynamic message, whose descriptor may have been constructed dynamically (such as being parsed from source). In that case, the `protoreflect` stuff will happily panic when it sees the mismatch 😱. This commit fixes this issue so that custom feature values can be successfully queried under these conditions, without panic.
- Loading branch information
Showing
2 changed files
with
229 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters