Skip to content

Connect client return an invalid_argument error when decoding an anypb.Any message #689

Answered by timostamm
coobeet asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @coobeet, the message google.protobuf.Any is just string field for the type name and a bytes field for the data. If you parse an Any from binary, the packed message remains serialized until you unpack it. To unpack it, the concrete type information is required. In the JSON format, Any is is not just a slice of bytes with a name, but the actual fields of the packed message are part of the JSON object. Therefore, concrete type information is required to parse from JSON, not just to unpack.

In Go, the type is automatically looked up in a global registry that is populated at package init. Our protobuf implementation does not have a global registry because it would hamper tree-shaking, and…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by coobeet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants