Skip to content

Conversation

@fmeum
Copy link
Collaborator

@fmeum fmeum commented Sep 30, 2025

Motivating examples for adding this type:

  • Packaging rules that bundle targets into substructures (e.g. subdirectories).
  • Providing hints to aspects via a well-known implicit attribute mapping the names of other attributes to a list of well-known targets representing the semantic meaning of an edge (e.g. "compile time dep", "runtime dep", "third party dep", ...) for use in SBOM generation and packaging.
  • rules_js and other rulesets have patches parameters on their module extensions that accept lists of patches to apply per external dependency. With WORKSPACE, they relied on attr.string_list_dict, but the lack of repo mapping means that there is no direct port. Users would need to migrate to individual tags per hub repo and dep to supply patches.

Adding this type doesn't incur a significant maintenance cost:

  • The native attribute type LABEL_LIST_DICT already exists (added for exec_group_compatible_with), so this only requires wiring it up in Starlark. In fact, some of the added logic (duplicate checking) is relevant for this existing use case, we just forgot to add it.
  • A Starlark type with equivalent BUILD syntax already exists (attr.string_list_dict), so there is no need for tooling to explicitly support the new type.

Fixes #7989

RELNOTES[NEW]: The new attr.label_list_dict type accepts a dict in which keys are strings and values are lists of labels.

@fmeum fmeum force-pushed the 7989-label-list-dict branch 2 times, most recently from 138edea to 6146d60 Compare September 30, 2025 14:02
@fmeum fmeum requested a review from lberki September 30, 2025 14:34
@fmeum fmeum marked this pull request as ready for review September 30, 2025 14:34
@fmeum fmeum requested review from a team, Wyverald and meteorcloudy as code owners September 30, 2025 14:34
@fmeum fmeum requested review from gregestren and removed request for a team, Wyverald, gregestren and meteorcloudy September 30, 2025 14:34
@fmeum
Copy link
Collaborator Author

fmeum commented Sep 30, 2025

@lberki Choosing you as a reviewer based on #7989 (comment) :-)

@github-actions github-actions bot added team-Configurability platforms, toolchains, cquery, select(), config transitions team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Sep 30, 2025
@meteorcloudy
Copy link
Member

ping @lberki

Copy link
Contributor

@lberki lberki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay. Even today, I only had time to review the production code, but not the tests.

fmeum added 2 commits October 28, 2025 15:28
Motivating examples for adding this type:
* Packaging rules that bundle targets into substructures (e.g. subdirectories).
* Providing hints to aspects via a well-known implicit attribute mapping the names of other attributes to a list of well-known targets representing the semantic meaning of an edge (e.g. "compile time dep", "runtime dep", "third party dep", ...) for use in SBOM generation and packaging.
* rules_js and other rulesets have `patches` parameters on their module extensions that accept lists of patches to apply per external dependency. With WORKSPACE, they relied on `attr.string_list_dict`, but the lack of repo mapping means that there is no direct port. Users would need to migrate to individual tags per hub repo and dep to supply patches.

Adding this type doesn't incur a significant maintenance cost:
* The native attribute type `LABEL_LIST_DICT` already exists (added for `exec_group_compatible_with`), so this only requires wiring it up in Starlark.
* A Starlark type with equivalent BUILD syntax already exists (`attr.string_list_dict`), so there is no need for tooling to explicitly support the new type.

RELNOTES[NEW]: The new `attr.label_list_dict` type accepts a dict in which keys are strings and values are lists of labels.
@fmeum fmeum force-pushed the 7989-label-list-dict branch from 6146d60 to a7e165e Compare October 28, 2025 14:46
@fmeum fmeum requested a review from lberki October 28, 2025 14:48
@lberki
Copy link
Contributor

lberki commented Oct 29, 2025

Let's merge this then. @fmeum 's been waiting long enough.

@lberki lberki added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Oct 29, 2025
Copy link
Contributor

@tetromino tetromino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabian, can you please also add the new type to AttributeType in stardoc_output.proto, and add support for it in AttributeInfoExtractor.java?

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 30, 2025

Fabian, can you please also add the new type to AttributeType in stardoc_output.proto, and add support for it in AttributeInfoExtractor.java?

That's already on master as the native type existed before I added the Starlark type in this PR.

Copy link
Contributor

@tetromino tetromino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabian, can you please also add the new type to AttributeType in stardoc_output.proto, and add support for it in AttributeInfoExtractor.java?

That's already on master as the native type existed before I added the Starlark type in this PR.

Ahh - of course, you added it in f99a46f. I apologize for misreading.

@copybara-service copybara-service bot closed this in b0f51a9 Nov 5, 2025
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Nov 5, 2025
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 5, 2025

@bazel-io fork 9.0.0

@fmeum fmeum deleted the 7989-label-list-dict branch November 5, 2025 18:09
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Nov 5, 2025
Motivating examples for adding this type:
* Packaging rules that bundle targets into substructures (e.g. subdirectories).
* Providing hints to aspects via a well-known implicit attribute mapping the names of other attributes to a list of well-known targets representing the semantic meaning of an edge (e.g. "compile time dep", "runtime dep", "third party dep", ...) for use in SBOM generation and packaging.
* rules_js and other rulesets have `patches` parameters on their module extensions that accept lists of patches to apply per external dependency. With WORKSPACE, they relied on `attr.string_list_dict`, but the lack of repo mapping means that there is no direct port. Users would need to migrate to individual tags per hub repo and dep to supply patches.

Adding this type doesn't incur a significant maintenance cost:
* The native attribute type `LABEL_LIST_DICT` already exists (added for `exec_group_compatible_with`), so this only requires wiring it up in Starlark. In fact, some of the added logic (duplicate checking) is relevant for this existing use case, we just forgot to add it.
* A Starlark type with equivalent BUILD syntax already exists (`attr.string_list_dict`), so there is no need for tooling to explicitly support the new type.

Fixes bazelbuild#7989

RELNOTES[NEW]: The new `attr.label_list_dict` type accepts a dict in which keys are strings and values are lists of labels.

Closes bazelbuild#27119.

PiperOrigin-RevId: 828510272
Change-Id: Ibf5ba97d049e592af2f61d91dbaa42cfe264f0bb
@aignas
Copy link

aignas commented Nov 6, 2025

Can this also be cherry-picked to 8.x so that we have broader coverage? If the users start using attr.label_list_dict, they are locked to particular bazel versions.

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 6, 2025

@bazel-io fork 8.5.0

github-merge-queue bot pushed a commit that referenced this pull request Nov 6, 2025
Motivating examples for adding this type:
* Packaging rules that bundle targets into substructures (e.g.
subdirectories).
* Providing hints to aspects via a well-known implicit attribute mapping
the names of other attributes to a list of well-known targets
representing the semantic meaning of an edge (e.g. "compile time dep",
"runtime dep", "third party dep", ...) for use in SBOM generation and
packaging.
* rules_js and other rulesets have `patches` parameters on their module
extensions that accept lists of patches to apply per external
dependency. With WORKSPACE, they relied on `attr.string_list_dict`, but
the lack of repo mapping means that there is no direct port. Users would
need to migrate to individual tags per hub repo and dep to supply
patches.

Adding this type doesn't incur a significant maintenance cost:
* The native attribute type `LABEL_LIST_DICT` already exists (added for
`exec_group_compatible_with`), so this only requires wiring it up in
Starlark. In fact, some of the added logic (duplicate checking) is
relevant for this existing use case, we just forgot to add it.
* A Starlark type with equivalent BUILD syntax already exists
(`attr.string_list_dict`), so there is no need for tooling to explicitly
support the new type.

Fixes #7989

RELNOTES[NEW]: The new `attr.label_list_dict` type accepts a dict in
which keys are strings and values are lists of labels.

Closes #27119.

PiperOrigin-RevId: 828510272
Change-Id: Ibf5ba97d049e592af2f61d91dbaa42cfe264f0bb

Commit
b0f51a9

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Configurability platforms, toolchains, cquery, select(), config transitions team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need string_keyed_label_list_dict

5 participants