-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
JSON: 'Any' message should serialize to/from bytes when the message type is not well known. #4511
Comments
I found issue #658 which is relevant to this topic. I understand that it is valuable to be able to access the properties of types that are unknown. However, this precludes systems who serialize to JSON from being able to modify messages with unknown types. |
This issue is affecting a middleware gRPC proxy that translates messages from Proto to JSON. On RPC errors, details commonly contain Would be great to have support for |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment. This issue is labeled |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it. This issue was closed and archived because there has been no new activity in the 14 days since the |
Problem
The Any message type specifies that in JSON the properties of the message serialized within an Any message should be serialized as properties.
This forces a system that serializes using JSON with unregistered types to either throw an error because it does not know how to parse an unregistered type (code ref), or to gracefully skip the type and lose information (pull request #4505). If the latter is chosen, then when serializing or deserializing the message, information is lost.
Suggestion
When serializing to and from JSON, messages within an 'Any' message should serialize to and from bytes when the message type is not well known.
Figure 1: Example of serializing an 'Any' message with not well known type to bytes
Use Case
I have many systems that use common message types, but do not have all message types registered in all systems. They only register the message types that are relevant to them.
If system X requests data from system Y and system Z, system X should not have to know what the message types are in order to pack them into an 'Any'.
Thoughts
From my limited experience with Protocol Buffers, it seems like all message types have to be registered in the type registry in order to serialize and deserialize fully. This does not seem scalable when an organization shares thousands of message types, and messages are being sent to and from systems that need to modify message types that only they know how to modify, or add message types that only they know about.
This does not seem to be a problem with binary serialization, as in practice, it uses the
@value
property. However, I don't see the@value
property documented, so I don't know if this was intentional or not.Figure 2: Binary serialization uses the

@value
property when deserializing an unregistered typeThank you for taking the time to read through this issue.
The text was updated successfully, but these errors were encountered: