Note that this proto package is com.google and the imported package is google.protobuf.
When using the type google.protobuf.StringValue, according to protobuf namespace resolution rules, it should look for the StringValue type inside com.google.protobuf. This means the above proto file should fail in protoc and indeed it fails with the following message:
protoc service.proto -o /dev/null
service.proto:8:3: "google.protobuf.StringValue" is resolved to "com.google.protobuf.StringValue",
which is not defined.
The innermost scope is searched first in name resolution.
Consider using a leading '.'(i.e., ".google.protobuf.StringValue") to start from the outermost scope
)
In order to fix this, I need to use .google.protobuf.StringValue str = 1; (notice that dot prefix)
The problem is that buf, on the other hand, considers the above to be correct in both cases (with or without a leading .):
(notice how the typename is resolved to .google.protobuf.StringValue)
Important: This is not an edge case caused by the usage of google in package com.google.
It's an issue with namespace resolution that could occur also if the file was in com.xyz and there was another file with package xyz.something.else
The text was updated successfully, but these errors were encountered:
Consider the following proto:
Note that this proto package is
com.google
and the imported package isgoogle.protobuf
.When using the type
google.protobuf.StringValue
, according to protobuf namespace resolution rules, it should look for theStringValue
type insidecom.google.protobuf
. This means the above proto file should fail inprotoc
and indeed it fails with the following message:)
In order to fix this, I need to use
.google.protobuf.StringValue str = 1;
(notice that dot prefix)The problem is that
buf
, on the other hand, considers the above to be correct in both cases (with or without a leading.
):(notice how the typename is resolved to
.google.protobuf.StringValue
)Important: This is not an edge case caused by the usage of google in
package com.google
.It's an issue with namespace resolution that could occur also if the file was in
com.xyz
and there was another file with packagexyz.something.else
The text was updated successfully, but these errors were encountered: