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

TypeError: Cannot read property 'remove' of null #1165

Open
ashubham opened this issue Feb 9, 2019 · 7 comments
Open

TypeError: Cannot read property 'remove' of null #1165

ashubham opened this issue Feb 9, 2019 · 7 comments

Comments

@ashubham
Copy link

ashubham commented Feb 9, 2019

protobuf.js version: 6.8.3

When using --sparse option in the pbjs CLI command. It fails with an error

TypeError: Cannot read property 'remove' of null

pbjs -p ../ <proto_files> -t static-module -w es6 --sparse --force-message > out.js
at Root._handleRemove (/Users/ashish.shubham/code/thoughtspot/blink/node_modules/protobufjs/src/root.js:320:46)
    at Root._handleRemove (/Users/ashish.shubham/code/thoughtspot/blink/node_modules/protobufjs/src/root.js:338:18)
    at Type.onRemove (/Users/ashish.shubham/code/thoughtspot/blink/node_modules/protobufjs/src/object.js:131:14)
    at Namespace.remove (/Users/ashish.shubham/code/thoughtspot/blink/node_modules/protobufjs/src/namespace.js:263:12)
    at /Users/ashish.shubham/code/thoughtspot/blink/node_modules/protobufjs/cli/pbjs.js:284:28
    at traverse (/Users/ashish.shubham/code/thoughtspot/blink/node_modules/protobufjs/cli/util.js:47:5)
    at /Users/ashish.shubham/code/thoughtspot/blink/node_modules/protobufjs/cli/util.js:62:13
    at Array.forEach (<anonymous>)
    at traverse (/Users/ashish.shubham/code/thoughtspot/blink/node_modules/protobufjs/cli/util.js:61:29)
    at /Users/ashish.shubham/code/thoughtspot/blink/node_modules/protobufjs/cli/util.js:62:13

    at checkExecSyncError (child_process.js:611:11)
    at Object.execSync (child_process.js:648:13)
@JustinBeckwith
Copy link
Contributor

Greetings! Can you share the proto files you're using to get this?

@cyrilis
Copy link

cyrilis commented Apr 30, 2019

Hi @JustinBeckwith

I came into same error, and I uploaded the proto file I use.

pbjs --sparse -p "$GOPATH/src/github.com/gogo/protobuf" -p . -t json test.proto

Proto Files:
two-proto-files.zip

Thanks!

@natiz
Copy link

natiz commented Dec 8, 2019

+1

@acrazing
Copy link

acrazing commented Jan 8, 2020

I meet this again, it seems occurs when process extensions:

I import gogo/protobuf/gogo.proto to optimize emitted code, then it throws the error, I found it throws when process the extensionField:

image

image

@acrazing
Copy link

acrazing commented Jan 8, 2020

The minimum code to reproduce the error:

syntax = "proto3";
package stmp.examples.gomoku;

option go_package = "github.com/acrazing/stmp-go/examples/gomoku/gomoku_pb;pb";

import "github.com/envoyproxy/protoc-gen-validate/validate/validate.proto";
//import "stmp/stmp.proto";

// disable this for avoid pbjs throws error
import "github.com/gogo/protobuf/gogoproto/gogo.proto";

option (gogoproto.description_all) = false;
option (gogoproto.goproto_unrecognized_all) = false;
option (gogoproto.goproto_extensions_map_all) = false;
option (gogoproto.goproto_unkeyed_all) = false;
option (gogoproto.goproto_sizecache_all) = false;

message Empty {
}

execute:

	yarn pbjs -t static-module -w commonjs -p ./vendor -p . \
		--no-create --no-verify \
		--no-convert --no-delimited --keep-case --sparse \
		-o ./examples/gomoku/gomoku_pb/gomoku.pb.js ./examples/gomoku/gomoku_pb/*.proto

@aSapien
Copy link

aSapien commented Jul 29, 2020

Still happening with version 6.10.1

@ping-localhost
Copy link

For me adding the following was enough to resolve the issue:

if (object.extensionField.parent !== null) {
    object.extensionField.parent.remove(object.extensionField);
}

No idea if that's good enough to open a merge request with though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants