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

outputSchema=true throwing when compiling googleapis protos #975

Open
rosslavery opened this issue Dec 8, 2023 · 3 comments
Open

outputSchema=true throwing when compiling googleapis protos #975

rosslavery opened this issue Dec 8, 2023 · 3 comments

Comments

@rosslavery
Copy link

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 🙃

@tmtd4c93aac
Copy link

I found that protoc 22.3 is the last version without this throw, protoc 23.0 onward has this issue.

@shubhamshah207
Copy link

Any chance this can be fixed ? Getting same error.

@rektdeckard
Copy link

rektdeckard commented Jul 31, 2024

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.

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

4 participants