bazelbuild / bazelbuild/rules_license

gather_metadata doesn't transitively handle the label_keyed_string_dict_type

Open
#160 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
85
Forks
37
PR merge metrics
No merged PRs in 30d

Description

## Expected Behavior
When generating a transitive metadata list using the @rules_license//rules_gathering:gather_metadata.bzl%gather_metadata_info_and_write aspect we expect all metadata for the complete dependency tree to be collected.

## Actual Behavior
Dependency tree is cut when reaching an attribute with the label_keyed_string_dict_type.

## Steps to Reproduce the Problem

1. Declare a rule with an attribute with type label_keyed_string_dict_type
2. Instantiate the rule and add dependencies to a licensed target on the dict -> string format
3. Execute the aspect and notice how the license information is lost in the aggregation

## Proposed solution
Extend label_keyed_string_dict_type in licenses_core.bzl to also expand the dict keys.

Example:
```
dict_deps = []
for dep in a:
if type(dep) == 'dict':
for d in dep.keys():
if type(d) != 'list':
dict_deps.append(d)
else:
dict_deps.extend(d)
for dep in a + dict_deps:
# Ignore anything that isn't a target
if type(dep) != "Target":
continue
```

## Specifications

- Version: 1.0.0
- Platform: linux

Contributor guide

Open the contributing guide

Research direction

Start with licenses_core.bzl and the gather_metadata_info_and_write aspect in rules_gathering/gather_metadata.bzl. Reproduce the issue with a rule using label_keyed_string_dict_type, then verify that the generated transitive metadata includes license information from dependencies stored in the dictionary keys.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.