-
Notifications
You must be signed in to change notification settings - Fork 679
Open
Description
Problem description
When marking a custom field option as optional, loadSync
throws a the following error
TypeError: Cannot read properties of undefined (reading 'indexOf')
Note this error only occurs when using optional
Reproduction steps
- Clone https://github.com/ehyland/tmp-proto-loader-issue
- Install dependencies
npm i
- Run test script
node test-with-optional.js
Environment
- OS & Arch: MacOS 12.2 - amd64
- Node:
v16.13.0
- Node installation method:
nvm
- Package name and version:
@grpc/[email protected]
Additional context
Error with stack
./node_modules/protobufjs/ext/descriptor/index.js:488
if ((descriptor.oneofIndex = this.parent.oneofsArray.indexOf(this.partOf)) < 0)
^
TypeError: Cannot read properties of undefined (reading 'indexOf')
at Field.toDescriptor (./node_modules/protobufjs/ext/descriptor/index.js:488:62)
at Root_toDescriptorRecursive (./node_modules/protobufjs/ext/descriptor/index.js:142:40)
at Root_toDescriptorRecursive (./node_modules/protobufjs/ext/descriptor/index.js:146:13)
at Root.toDescriptor (./node_modules/protobufjs/ext/descriptor/index.js:121:5)
at createPackageDefinition (./node_modules/@grpc/proto-loader/build/src/index.js:148:33)
at Object.loadSync (./node_modules/@grpc/proto-loader/build/src/index.js:195:12)
at Object.<anonymous> (./test.js:6:13)
Proto file that will fail to load
See https://github.com/ehyland/tmp-proto-loader-issue to reproduce
syntax = "proto3";
package example;
import "google/protobuf/descriptor.proto";
extend google.protobuf.FieldOptions {
optional bool sensitive = 99999;
}
message MyMessage {
string id = 1;
string secret_sauce = 3 [(example.sensitive) = true];
}