Skip to content

Descriptor-less reflection: nested messages/enums can't be resolved by clients (grpcurl fails) #92

Closed

Description

@mjheilmann

When protos are compiled without descriptors (gen_descriptors off), the synthesized file descriptors for nested types are wrong, and clients can't resolve them. The server replies OK, but grpcurl fails.

Reproduction

The existing NoDescriptor.Nested.* fixture, generated from priv/protos/nested/nested_messages.proto, has no test. Running grpcurl describe against NoDescriptor.Nested.NestedService.Service gives:

Failed to list methods for service "nested.NestedService": proto: message field
"nested.DeepMessage.very_deep" cannot resolve type:
"nested.OuterMessage.MiddleMessage.InnerMessage.DeepMessage.VeryDeepMessage" not found

This also blocks a descriptor-less test for the nested self-reference case from #91. That case is currently skipped via @skip_no_descriptor in mix.exs.

Cause

  • Synthesizer.message_descriptor/1 always emits nested_type: [].
  • Builder instead emits each nested type as its own top-level file, for example nested.OuterMessage.MiddleMessage.proto.
  • Util.get_package/1 drops capitalized segments, so that file gets package: "nested" and a message named MiddleMessage. It therefore defines nested.MiddleMessage.
  • Fields still reference .nested.OuterMessage.MiddleMessage, which no file defines.
  • The comment in synthesizer.ex says this layout is "handled correctly by standard reflection clients". That is not true for grpcurl.

Likely fix

Mirror the descriptor path: embed nested message and enum descriptors in the parent DescriptorProto, and keep nested symbols in the parent's file, as trace_field_ref already does when descriptors are present. This probably also means:

  • Deriving nesting from module full_name, since Elixir module names can't distinguish nested types from top-level ones.
  • Handling map-entry types, which are currently emitted as separate files.

Acceptance

  • Add descriptor-less tests (grpcurl traversal plus file_containing_symbol) for nested, nested_enum_conflict and nested_self_reference.
  • Remove nested_self_reference.proto from @skip_no_descriptor.
  • Update or remove the misleading comment in synthesizer.ex.

Found while reviewing: #91 (the bug exists on main, independent of that PR).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions