ts-proto
ts-proto copied to clipboard
`outputSchema=true` throwing when compiling `googleapis` protos
Hi there,
Running with the following options is throwing with the below error.
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto \
--experimental_allow_proto3_optional \
--proto_path $path \
--ts_proto_out=$outdir \
--ts_proto_opt=outputSchema=true \
./google/ads/googleads/$version/**/*.proto
FAILED!Cannot read properties of undefined (reading '17')TypeError: Cannot read properties of undefined (reading '17')
at encodedOptionsToOptions (/Users/someuser/Desktop/Work/somerepo/node_modules/.pnpm/[email protected]/node_modules/ts-proto/build/schema.js:191:51)
at /Users/someuser/Desktop/Work/somerepo/node_modules/.pnpm/[email protected]/node_modules/ts-proto/build/schema.js:203:34
at Array.forEach (<anonymous>)
at resolveMessageOptions (/Users/someuser/Desktop/Work/somerepo/node_modules/.pnpm/[email protected]/node_modules/ts-proto/build/schema.js:201:19)
at /Users/someuser/Desktop/Work/somerepo/node_modules/.pnpm/[email protected]/node_modules/ts-proto/build/schema.js:86:33
at Array.forEach (<anonymous>)
at generateSchema (/Users/someuser/Desktop/Work/somerepo/node_modules/.pnpm/[email protected]/node_modules/ts-proto/build/schema.js:85:34)
at generateFile (/Users/someuser/Desktop/Work/somerepo/node_modules/.pnpm/[email protected]/node_modules/ts-proto/build/main.js:252:52)
at /Users/someuser/Desktop/Work/somerepo/node_modules/.pnpm/[email protected]/node_modules/ts-proto/build/plugin.js:43:54
at Array.map (<anonymous>)--ts_proto_out: protoc-gen-ts_proto: Plugin failed with status code 1.
Which points to this line (reading '17' of extensionCache[extendee]):
const extension = extensionCache[extendee][parseInt(key, 10) >>> 3];
Looking to output the schema to use in some downstream tooling, but not having any luck 🙃
I found that protoc 22.3 is the last version without this throw, protoc 23.0 onward has this issue.
Any chance this can be fixed ? Getting same error.
Experiencing the same with [email protected] and my own protos. There are a number of cases where extensionCache[extendee] is undefined, and I was able to hack around the problem and get it to compile by modifying the code in question to:
const extension = extensionCache[extendee]?.[parseInt(key, 10) >>> 3];
if (extension) {
resultOptions.push(getExtensionValue(ctx, extension, value));
}
Unsure yet if this produces good behavior or breaks some assumptions.