danielgtaylor / danielgtaylor/python-betterproto

Missing data in proto maps

オープン
#442 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
1.8k
フォーク
234
PR マージ指標
30日以内にマージされた PR はありません

説明

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": {}
}
]
}
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

issue の proto 定義から始め、MeasurementMap 内に値がゼロの Measurement を含む WeatherStation のレスポンスを再現します。rpi2 の map エントリに対する betterproto の出力を grpclib の出力と比較し、その後、レスポンスに空の値オブジェクトが含まれていて省略されていないこと、また Postman が正常に解析できることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
grpc, python
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。