-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Cannot read properties of undefined (reading 'indexOf') #1958
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
Comments
We ran into this same issue. It seems to occur when an extend google.protobuf.FieldOptions {
optional NfTrackerInfo nfTrackerInfo = 50001;
} I see the original report above mentions |
Here is a minimal repro of the issue in // extend.proto
syntax = "proto3";
message SomeMessage {
string foo = 1;
}
extend SomeMessage {
optional string bar = 2;
} // index.mjs
import protobufjs from 'protobufjs';
import descriptor from 'protobufjs/ext/descriptor/index.js';
import path from 'path';
const dirname = path.dirname(new URL(import.meta.url).pathname);
const root = protobufjs.loadSync(path.join(dirname, 'extend.proto'));
root.toDescriptor('proto3').file; And the error:
|
FWIW it looks like the reason the existing tests do not hit this issue is because |
protobuf.js version: 7.2.5
gprc-js version 1.9.13
proto-loader version 0.7.10
line #488 of [protobuf.js/ext/descriptor/index.js]
causes the error Cannot read properties of undefined (reading 'indexOf') when calling proto-loader's loadSync function.
This specifically happens when the latest version of buf/validate.proto is among the proto files being used.
Changing line #488 to below solves the issue,
if ((this.parent.oneofsArray && descriptor.oneofIndex = this.parent.oneofsArray.indexOf(this.partOf)) < 0)
Stacktrace
I see a somewhat similar issue, #1898 but no resolution.
The text was updated successfully, but these errors were encountered: