bazel-contrib / bazel-contrib/rules_go

gopackagesdriver: bug when working with go_proto_library when compiler argument is specified.

Open
#3,435 0 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

### What version of rules_go are you using?

0.37.0

### What version of gazelle are you using?

0.28.0

### What version of Bazel are you using?

6.0.0-pre.20221012.2

### Does this issue reproduce with the latest releases of all the above?

Yes

### What operating system and processor architecture are you using?

Debian, x86_64

### Any other potentially useful information about your toolchain?

N/A

### What did you do?

Defined a go_proto_library target with a custom compiler argument.

```
go_proto_library(
name = "test_lib",
compiler = ":custom_go_compiler",
protos = ["a.proto"],
# ...
)
```

Later, gopackagesdriver stops working in my VSCode and after debugging, saw this error:

```
.../io_bazel_rules_go/go/tools/gopackagesdriver/aspect.bzl", line 81, column 20, in _go_pkg_info_aspect_impl
for dep in getattr(ctx.rule.attr, attr, []) or []:
Error: type 'Target' is not iterable
```

### What did you expect to see?

gopackagesdriver should work.

### What did you see instead?

it didn't work. it is because a bug in gopackagedriver bzl defines. https://github.com/bazelbuild/rules_go/blob/master/proto/def.bzl#L173-L177 specifies that `compiler` flag is a single target, not an iterable object. However, https://github.com/bazelbuild/rules_go/blob/master/go/tools/gopackagesdriver/aspect.bzl#L83-L84 iterates over that field.

Contributor guide

Open the contributing guide

Research direction

Start with proto/def.bzl around lines 173-177 and go/tools/gopackagesdriver/aspect.bzl around lines 81-84. Reproduce the failure using a go_proto_library with a custom compiler argument, then trace how the compiler attribute is consumed by the aspect. Done means gopackagesdriver handles this target without the Target-not-iterable error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.