Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on toObject when a message has a nested messge with unordered value #729

Closed
yagop opened this issue Mar 27, 2017 · 0 comments
Closed

Comments

@yagop
Copy link

yagop commented Mar 27, 2017

protobuf.js version: master (tested on 8de21e1)

I know master branch is not published but I want to report this behavior, maybe is unknown. In 6.6.5 is working fine.

const protobuf = require("protobufjs");

const proto = `
package main;

message Foo {
  optional Bar bar = 2;
  optional string a = 1;
  message Bar {
  }
}
`

const root = protobuf.parse(proto).root;

const Foo = root.lookupType('main.Foo');

const foo = Foo.create({
  bar: Foo.Bar.create({})
});

const buffer = Foo.encode(foo).finish();
const msg = Foo.decode(buffer);
console.log(Foo.toObject(msg));
➜ node test.js                                                         
undefined:15
		d["bar"]=types[1].toObject(m["bar"],o)
		                 ^

TypeError: Cannot read property 'toObject' of null
    at Type._main_Foo$toObject [as toObject] (eval at eof (/tmp/tmp.smwHGIzVCY/node_modules/@protobufjs/codegen/index.js:103:25), <anonymous>:15:20)
    at Object.<anonymous> (/tmp/tmp.smwHGIzVCY/test.js:24:17)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:425:7)
    at startup (bootstrap_node.js:146:9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant