-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Description
What version of protobuf and what language are you using?
Version: main (initially encountered on 6.31.1)
Language: Python
What operating system (Linux, Windows, ...) and version?
Linux (Ubuntu 24.04.3)
What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.10.19
What did you do?
Steps to reproduce the behavior:
- Created an
Anymessage containing anEmptyvalue - Serialized the message to JSON using Go
- Deserialized the message from JSON using Python
What did you expect to see
The deserialized Any message containing an Empty value.
The Go serializer produced the following JSON:
{
"@type": "type.googleapis.com/google.protobuf.Empty",
"value": {}
}This is the correct serialization, according to the spec: https://protobuf.dev/programming-guides/json/#field-representation
What did you see instead?
Parse error:
ParseError: Failed to parse (elided) field: Message type "google.protobuf.Empty" has no field named "value" at "(elided)".
Available Fields(except extensions): "[]".
The Python deserializer expects the following JSON:
{
"@type": "type.googleapis.com/google.protobuf.Empty"
}The root cause appears to be that json_format.py does not include google.protobuf.Empty in its list of well-known types (_WKTJSONMETHODS), and it is also not a wrapper type.
Anything else we should know about your project / environment
n/a