ruby-protobuf / protobuf

A pure ruby implementation of Google's Protocol Buffers
https://github.com/ruby-protobuf
MIT License
462 stars 101 forks source link

Unable to generate protobuffs with `map` types as return in service. #388

Open Mythra opened 6 years ago

Mythra commented 6 years ago

I'm attempting to generate the protobuff for:

syntax = "proto2";

option java_multiple_files = true;
option java_package = "com.test.grpc";
option java_outer_classname = "TestProto";

package com.test.grpc;

message TestMsg {
  required string primary_key = 1;
  map<string, string> data = 2;
}

service TestSvc {
  rpc Store(String) returns (TestMsg);
}

However attempting to compile this proto results in an error:

 protoc -I ../../../proto/ --ruby_out ./lib ../../../proto/test_case.proto 
test_case.proto:11:3: Expected "required", "optional", or "repeated".
test_case.proto:11:6: Expected field name.

I've confirmed removing the map type causes the error to not be generated, and confirmed that removing the service TestSvc would also fix this issue.

I'm not sure if this is something I'm doing wrong with protobuffs, or if it's a problem with the compiler, but other language bindings seem to generate this code fine.