bazel-contrib / bazel-contrib/rules_go
misleading error message for missing `protos` attribute on go_proto_library
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 762
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
This was the first time I used go_proto_library in a long time. I had
```
go_proto_library(
name = "metrics_go_proto",
compilers = [
"@@//lang/rpc:go_proto_compiler",
],
importpath = "xxxx",
deps = [":metrics_proto"],
)
```
which is incorrect (should use `protos` iso. `deps`). The error message for this is
```
ERROR: xx/BUILD:5:14: in @@rules_go+//proto:def.bzl%_go_proto_aspect aspect on proto_library rule //xx/proto:metrics_proto:
Traceback (most recent call last):
File "/home/hanwen/.cache/bazel/_bazel_hanwen/9456475fcdc74345a14b5217fb53a469/external/rules_go+/proto/def.bzl", line 76, column 26, in _go_proto_aspect_impl
importpath = attr.importpath,
Error: No attribute 'importpath' in attr. Make sure you declared a rule attribute with this name.
Available attributes: _action_listener, _config_dependencies, _experimental_proto_descriptor_sets_include_source_info, _proto_compiler, _strict_proto_deps, _strict_public_imports, allow_exports, aspect_hints, compatible_with, data, deprecation, deps, exec_compatible_with, exec_properties, expect_failure, exports, features, generator_function, generator_location, generator_name, import_prefix, licenses, name, package_metadata, restricted_to, srcs, strip_import_prefix, tags, target_compatible_with, testonly, toolchains, transitive_configs, visibility
```
this is confusing, because there is an 'importpath' attribute on go_proto_library.
The docs say that `protos` is a required attribute. Would it be possible to check this and emit an error message?
Contributor guide
Research direction
Reproduce the issue from the shown BUILD snippet, then inspect the go_proto_library entry point and external/rules_go+/proto/def.bzl around line 76. Confirm how a missing protos attribute reaches the aspect, and consider the diagnostic complete when it identifies the required protos attribute instead of reporting a misleading importpath error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100