Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

JS Unexpected behavior when serializing/deserializing

オープン
#51 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript

調査の方向性

issue に示されている setPkid/serializeBinary/deserializeBinary のシーケンスを再現します。MyMessage の setter とシリアライズ/デシリアライズのエントリポイントを追跡し、数値が空文字列になる箇所を特定します。想定される型処理について、maintainer が承認した fix があるか、文書化された判断がなされれば完了です。

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

説明

bug javascript port-fix triaged

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:

  1. Setting the field with setPkid to crash (or a warning) because the type is not what was expected
  2. Serialization crashing (or a warning) because the type is not expected
  3. Coercing the type using toString which 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時間
マージ済み PR(30日)
6

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

protocolbuffers/protobuf-javascript のほかの issue

protocolbuffers/protobuf-javascript の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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