danielgtaylor / danielgtaylor/python-betterproto
Missing data in proto maps
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
I have a theoretical proto file message defined as:
```
message Measurement {
double pressure = 1;
double temperature = 2;
}
message MeasurementMap {
map measurements = 1;
}
service WeatherStation {
rpc GetClimate (Empty) returns (MeasurementMap) {}
}
```
The problem is that if `MeasurementMap` contains a `Measurement` with all fields equal to 0, betterproto server replies with something like this:
```
{
"measurements": [
{
"key": "rpi1",
"value": {
"pressure": 1.01,
"temperature": 25.2,
}
},
{
"key": "rpi2"
}
]
}
```
Second key does not have any value next to it which makes _Postman_ throw a tantrum about "null value not having **pressure** field"
For comparison, here is the default behaviour of _grpclib_, which _Postman_ receives and parses A-OK:
```
{
"measurement": [
{
"key": "rpi1",
"value": {
"pressure": 1.01,
"temperature": 25.2
}
},
{
"key": "rpi2",
"value": {}
}
]
}
```
Contributor guide
Assessment
This issue has not been assessed yet.