bazelbuild / bazelbuild/rules_license
gather_licenses_info_common does not traverse inputs via label_keyed_dict(s)
- Dominant language
- Starlark
- Stars
- 85
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
## Expected Behavior
Should traverse the dependencies, and pickup all licenses
## Actual Behavior
The dict is not which are not list and is converted to a list of a dict so the labels are not traversed. Instead the keys from the dict should be traversed.
## Steps to Reproduce the Problem
1. Define a rule which takes a `attr.label_keyed_string_dict`
1. Add a label as an input to that rule which has a license
1. Check that gather licenses using the rule defined above
## Specifications
```
diff --git a/C:/dev/rules_license-0.0.4/rules/licenses_core.bzl b/rules_license/rules/licenses_core.bzl
index 42702bdb7d..fae491539e 100644
--- a/C:/dev/rules_license-0.0.4/rules/licenses_core.bzl
+++ b/rules_license/rules/licenses_core.bzl
@@ -74,7 +74,9 @@ def _get_transitive_licenses(ctx, trans_licenses, trans_deps, traces, provider,
a = getattr(ctx.rule.attr, name)
# Make anything singleton into a list for convenience.
- if type(a) != type([]):
+ if type(a) == type({}):
+ a = a.keys()
+ elif type(a) != type([]):
a = [a]
for dep in a:
# Ignore anything that isn't a target
```
- Version: 0.0.4
- Platform: all
Contributor guide
Research direction
Start in rules/licenses_core.bzl at _get_transitive_licenses and inspect how ctx.rule.attr inputs are normalized before dependencies are traversed. Reproduce the label_keyed_string_dict case described in the issue, then verify that dictionary keys are traversed and all dependency licenses are gathered.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100