bazel-contrib / bazel-contrib/rules_go

go_grpc_v2 fails when one or more of the proto files in the package has no service statement

Open
#4,346 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start with the go_grpc_library handling used by go_grpc_v2 and compare its expected outputs with the grpc plugin behavior for proto files without a service statement. Reproduce the failure with a package containing service and message-only files, then verify that the build no longer expects an _grpc.pb.go artifact for files the plugin skips.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, grpc
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.