JS Unexpected behavior when serializing/deserializing
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- javascript
研究方向
重現 issue 中所示的 setPkid/serializeBinary/deserializeBinary 序列。追蹤 MyMessage setter 以及序列化/反序列化進入點,以找出數值在哪裡變成空字串。當預期的型別處理有一個經 maintainer 核准的 fix,或有一項已記錄的決定時,即視為完成。
由索引模型根據 Issue 內容生成。
描述
Hello opening this issue because I've seen an unexpected behavior and want to discuss about it and see what's the best pattern
Given the following message:
message MyMessage {
String pkid = 1;
}
If I set a number field into pkid, I'm able to retrieve it correctly. Once I serialize and then deserialize the message, the value gets coerced as an empty string:
> protoConfig.setPkid(123);
> protoConfig.getPkid();
123
> MyMessage.deserializeBinary((protoConfig.serializeBinary())).getPkid()
""
I wasn't expecting the field to be transformed silently once the message is serialized. What I would expect from order of preference:
- Setting the field with
setPkidto crash (or a warning) because the type is not what was expected - Serialization crashing (or a warning) because the type is not expected
- Coercing the type using
toStringwhich would set it to '123'
I understand suggested behaviors may have performance implications but I'm not sure what's the reason of current behavior because this still forces the user to do type checks before setting fields in a protobuf message when using javascript? IMO silently changing the value of a field when serializing a message is dangerous and I would aim for correctness of data first.
- 主要語言
- JavaScript
- 星號
- 471
- 分支
- 91
- 平均合併
- 1 天 12 小時
- 30 天內合併 PR
- 6
環境準備
我們還沒有檢查這個專案的環境設定檔。先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
protocolbuffers/protobuf-javascript 的其他 Issue
-
難度 5/5 一週以上 新手友好度 25/100
-
難度 5/5 一週以上 新手友好度 30/100
protocolbuffers/protobuf-javascript#248 · 1 則留言 · 13 個 reaction ·
-
question
難度 3/5 1-2 天 新手友好度 45/100
protocolbuffers/protobuf-javascript#222 · 9 則留言 ·
-
enhancement port-fix triaged
難度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#185 · 1 則留言 ·
-
enhancement port-fix triaged
難度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#182 · 3 則留言 · 1 個 reaction ·
查看 protocolbuffers/protobuf-javascript 的全部 Issue
相似的 Issue
-
feature task
難度 2/5 1-3 小時 新手友好度 72/100
RealDevSquad/website-www#1178 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
netlify-labs/nax#56 · 2 則留言 · 1 個 reaction ·
-
accessibility bug revealjs
難度 2/5 1-3 小時 新手友好度 84/100
quarto-dev/quarto-cli#14961 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
PnX-SI/GeoNature#4435 · 2 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 85/100
openlayers/openlayers#17648 ·
維護者通常 1 天內回覆