AssertionError: Assertion failed when deserializing message from python in js
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, node.js, python
调研方向
从链接的示例仓库开始,在安装其 requirements 后运行 node test.js 和 python3 test.py。使用报告中的字节序列和堆栈跟踪作为复现依据,将 demo_pb.js 中的反序列化路径与 Python 结果进行比较。只有当消息在 JavaScript 和 Python 中都能成功反序列化且不出现 AssertionError 时,才算完成。
由索引模型根据 Issue 内容生成。
描述
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:
- Defined these protos:
syntax = "proto2";
message B {
optional string b2 = 2;
}
message A {
optional B b = 1;
optional string id = 2;
}
- 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 分钟
- 30 天内合并 PR
- 2
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 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
-
难度 2/5 1-3 小时 新手友好度 65/100
antfu-collective/icones#398 ·
-
ECmail.com 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
wesbos/burner-email-providers#554 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
radiantearth/stac-browser#1023 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
components-web-app/docs#92 ·