Protobuf: Same name for rpc and message cause name conflict

Created on 16 Jul 2017  路  3Comments  路  Source: protocolbuffers/protobuf

I think it's not mentioned in ProtoBuf guide (https://developers.google.com/protocol-buffers/docs/proto3#packages-and-name-resolution)

Proto definition:

message Version {
  string version = 1;
}

service Config {
  rpc Version(google.protobuf.Empty) returns (Version) {}
}

Error:

services.proto:97:49: "Version" is not a message type.
documentation

Most helpful comment

The self-explanatory message would be:
rpc "Version" name collides with message Message in line N.

The current message, for me caused a bit of mind fuck, checking if i'm compiling the correct .proto and so on.

All 3 comments

Perhaps we could update the docs?

The package and name resolution talks mostly about how to implicitly look up types in namespaces.

The case you raised are actually quite common, and I don't think we have a full list of cases where symbol names may conflict. Given the error message is already self-explanatory, I don't think adding a partial conflicting list would add too much value, as users would probably try define the same name and will immediately get the compile error.

The self-explanatory message would be:
rpc "Version" name collides with message Message in line N.

The current message, for me caused a bit of mind fuck, checking if i'm compiling the correct .proto and so on.

Was this page helpful?
0 / 5 - 0 ratings