go_grpc_v2 fails when one or more of the proto files in the package has no service statement
rules_go v0.54.0
I have a bunch of GRPC services which used to compile just fine with "go_grpc". I'm trying to use "go_grpc_v2" to compile the same packages, and it fails with the following uninspiring errors:
file "bazel-out/k8-fastbuild/bin/schema/protobuf/fancysvc/go_proto_/schema/protobuf/fancysvc/somefile_grpc.pb.go" expected from plugin "bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_go+/proto/go_grpc_v2_reset_plugin_/protoc-gen-go-grpc" but not created
It so happens, that my package has a bunch of proto files, and some of those files have no service directive in them (because they contain definitions of various sort). For those files, only "somefile.pb.go" artifacts are produced. This causes the build to fail.
I understand, that go_grpc_library rule simply assumes, that each proto file will produce both ".pb.go" file and "_grpc.pb.go" file. However, it seems that grpc plugin simply skips files which have no service block in them, producing no output.
Can this be fixed? Even relatively simple GRPC services may require great many messages and enums defined across multiple proto files.
https://github.com/grpc/grpc-go/blob/f2d3e11f3057cc8b4935fc342446ae8372de33d3/cmd/protoc-gen-go-grpc/grpc.go#L136
Seems like the actual plugin was always working like described, but packages were still compiling.
Could you check whether https://github.com/bazel-contrib/rules_go/commit/66cd5f5ea009cfe349de526772a7e877cdd76d34 fixes this?
@fmeum I just tried out that commit, and it resolved this error for me. Thanks!
archive_override(
module_name = "rules_go",
integrity = "sha256-MM08acUc2iw4L3zoGQwaf5+ACZ6EOdwioRy5TaWsaRE=",
strip_prefix = "rules_go-66cd5f5ea009cfe349de526772a7e877cdd76d34",
urls = ["https://github.com/bazel-contrib/rules_go/archive/66cd5f5ea009cfe349de526772a7e877cdd76d34.zip"],
)
The fix compiles for me as well.
I had to switch back to go_grpc because it says "undefined: [thing that is defined]" in the generated *_grpc.pb.go file, even though the thing is defined in the neighboring file without the _grpc.pb part. this is for a proto with a service statement, but this is the only go_grpc_v2 compatibility issue so it seems reasonable to report this here while the issue is open.