Skip to content

Ruby: grpc_ruby_plugin bug using ruby_package and nested resources #21561

@blowmage

Description

@blowmage

The grpc_ruby_plugin protoc plugin has a bug in generating Ruby output for proto files with nested resources and using the ruby_package option.

The plugin works fine when using either nested resources or ruby_package, but not both.

What version of gRPC and what language are you using?

grpc 1.26.0

What operating system (Linux, Windows,...) and version?

OS X

What runtime / compiler are you using (e.g. python version or version of gcc)

Ruby 2.6.2

What did you do?

Create a simple proto file that illustrates the issue:

mkdir -p input
mkdir -p output

cat << 'EOF' >> input/ruby_package_bug.proto
syntax = "proto3";

package grpc_ruby.ruby_package.bug_example;

option ruby_package = "Ruby::Package::Example";

service RubyPackageService {
  rpc GetInnerResource(GetInnerResourceRequest) returns (OuterResource.InnerResource) {
  }
}

message GetInnerResourceRequest {
  int32 id = 1;
}

message OuterResource {
  int32 id = 1;

  message InnerResource {
    string name = 1;
  }
}
EOF

Now generate the ruby output using the following:

protoc ruby_package_bug.proto -I input --ruby_out=output --grpc_out=output

Or, if you are using the grpc-tools gem, using the following:

grpc_tools_ruby_protoc ruby_package_bug.proto -I input --ruby_out=output --grpc_out=output

What did you expect to see?

The service should generate the rpc with the correct resource Ruby::Package::Example::OuterResource::InnerResource:

rpc :GetInnerResource, Ruby::Package::Example::GetInnerResourceRequest, Ruby::Package::Example::OuterResource::InnerResource

What did you see instead?

The service generates the rpc with the resource Ruby::Package::Example::InnerResource, which does not exist:

rpc :GetInnerResource, Ruby::Package::Example::GetInnerResourceRequest, Ruby::Package::Example::InnerResource

Anything else we should know about your project / environment?

Nope.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions