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

AssertionError: Assertion failed when deserializing message from python in js

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

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

評価

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

調査の方向性

リンクされたサンプルリポジトリから始め、必要な依存関係をインストールした後に node test.js と python3 test.py を実行します。報告されたバイト列とスタックトレースを再現手順として使用し、demo_pb.js のデシリアライズ経路を Python の結果と比較します。JavaScript と Python の両方で AssertionError を発生させずにメッセージのデシリアライズが成功すれば完了です。

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

説明

bug javascript port-fix triaged

What version of protobuf and what language are you using?
Version: v.3.11.2
Language: Python, Javascript

What operating system (Linux, Windows, ...) and version?
MacOS High Sierra Version 10.13.6

What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.7.3, NodeJS v13.3.0

What did you do?
Steps to reproduce the behavior:

  1. Defined these protos:
syntax = "proto2";

message B {
  optional string b2 = 2;
}

message A {
  optional B b = 1;
  optional string id = 2;
}
  1. Attempted to deserialize this message in both js and python: 0a060a0131120131181e10a3c6ad8dcdeed0a274

Here's a sample repo to reproduce: https://github.com/bhainesva/protobuf-py-vs-js-demo (run node test.js / python3 test.py after installing requirements).

What did you expect to see
I expected the deserialization to succeed in both python and js.

What did you see instead?
Python deserialization succeeds but js deserialization produces this error:

/Users/bhaines/repo/proto-demo/node_modules/google-protobuf/google-protobuf.js:81
jspb.BinaryConstants.TWO_TO_32=4294967296;jspb.BinaryConstants.TWO_TO_52=4503599627370496;jspb.BinaryConstants.TWO_TO_63=0x7fffffffffffffff;jspb.BinaryConstants.TWO_TO_64=1.8446744073709552E19;jspb.BinaryConstants.ZERO_HASH="\x00\x00\x00\x00\x00\x00\x00\x00";goog.dom={};goog.dom.NodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12};goog.debug={};goog.debug.Error=function(a){if(Error.captureStackTrace)Error.captureStackTrace(this,goog.debug.Error);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a));this.reportErrorToServer=!0};goog.inherits(goog.debug.Error,Error);goog.debug.Error.prototype.name="CustomError";goog.asserts={};goog.asserts.ENABLE_ASSERTS=goog.DEBUG;goog.asserts.AssertionError=function(a,b){goog.debug.Error.call(this,goog.asserts.subs_(a,b));this.messagePattern=a};goog.in
Error [AssertionError]: Assertion failed
    at new goog.asserts.AssertionError (/Users/bhaines/repo/proto-demo/node_modules/google-protobuf/google-protobuf.js:81:876)
    at Object.goog.asserts.doAssertFailure_ (/Users/bhaines/repo/proto-demo/node_modules/google-protobuf/google-protobuf.js:82:257)
    at Object.goog.asserts.assert (/Users/bhaines/repo/proto-demo/node_modules/google-protobuf/google-protobuf.js:83:83)
    at jspb.BinaryReader.readString (/Users/bhaines/repo/proto-demo/node_modules/google-protobuf/google-protobuf.js:394:64)
    at Function.proto.A.deserializeBinaryFromReader (/Users/bhaines/repo/proto-demo/demo_pb.js:263:49)
    at Function.proto.A.deserializeBinary (/Users/bhaines/repo/proto-demo/demo_pb.js:239:18)
    at Object.<anonymous> (/Users/bhaines/repo/proto-demo/test.js:13:20)
    at Module._compile (internal/modules/cjs/loader.js:1128:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:983:32) {
  message: 'Assertion failed',
  reportErrorToServer: true,
  messagePattern: 'Assertion failed'
}

Seems related to including unknown fields in messages but I'm not very familiar with protobuf, my understanding is that that's supported.

Potentially related to this issue? protocolbuffers/protobuf#4688.

主要言語
JavaScript
スター
471
フォーク
91
平均マージ
3時間 57分
マージ済み PR(30日)
2

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

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

protocolbuffers/protobuf-javascript のほかの issue

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

似ている issue

JavaScript の issue をもっと見る

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

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