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.
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 whoseSyntax
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 thanproto: invalid syntax: "<unknown:0>"
.So I think this logic should just skip setting the
Syntax
field (i.e. leave itnil
since it's a proto2 optional field) if the sourceprotoreflect.FileDescriptor
returns a syntax value wheresyntax.IsValid()
is false.