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

reflection/protodesc: placeholder files produce a descriptor with strange syntax value #1575

Closed
jhump opened this issue Nov 7, 2023 · 0 comments

Comments

@jhump
Copy link
Contributor

jhump commented Nov 7, 2023

When using protodesc.ToFileDescriptor to convert a file and its transitive dependencies to a *descriptorpb.FileDescriptorSet, if any of the files are placeholders (due to an imported file being absent from the registry, typically due to importing it using the wrong path), the result is a *descriptor.FileDescriptorProto message whose Syntax field is set to the string "<unknown:0>". While the resulting descriptor won't be usable (since it will be empty and thus not contain any of the symbols that the importing file expects), it seems like a link failure would be less surprising/more intuitive than proto: invalid syntax: "<unknown:0>".

So I think this logic should just skip setting the Syntax field (i.e. leave it nil since it's a proto2 optional field) if the source protoreflect.FileDescriptor returns a syntax value where syntax.IsValid() is false.

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

1 participant