JS Unexpected behavior when serializing/deserializing
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- backend-api-design
Direzione di ricerca
Riproduci la sequenza setPkid/serializeBinary/deserializeBinary mostrata nell’issue. Segui il setter di MyMessage e i punti di ingresso della serializzazione/deserializzazione per identificare dove il valore numerico diventa una stringa vuota. Il lavoro è considerato completato quando la gestione dei tipi prevista ha un fix approvato da un maintainer o una decisione documentata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 471
- Fork
- 91
- Merge medio
- 3h 57m
- PR unite (30g)
- 2
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di protocolbuffers/protobuf-javascript
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
protocolbuffers/protobuf-javascript#248 · 1 commento · 13 reazioni ·
-
question
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
protocolbuffers/protobuf-javascript#222 · 9 commenti ·
-
Why map.js sort keys? Apertaenhancement port-fix triaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
protocolbuffers/protobuf-javascript#185 · 1 commento ·
-
enhancement port-fix triaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
protocolbuffers/protobuf-javascript#182 · 3 commenti · 1 reazione ·
Tutte le issue di protocolbuffers/protobuf-javascript
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
agent/security hive/hosted-available-lke648397-260827-5n31 security
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bevyengine/bevy-website#2595 ·