[9.0.1] Support external repository labels in package_group (https://github.com/bazelbuild/bazel/pull/28811)#28895
Merged
meteorcloudy merged 1 commit intobazelbuild:release-9.0.1from Mar 5, 2026
Conversation
### Description This PR enables `package_group` to correctly interpret labels that include external repositories (e.g., `@module//...` or `@module//:__subpackages__`). ### Motivation Previously, `PackageSpecification.java` strictly required package names to start with `//`, failing on labels with repository prefixes. This made it impossible to define a `package_group` that includes packages from other Bzlmod modules. This change leverages `Label.parseWithRepoContext` to correctly resolve repository mapping and validate package specifications within the context of the repository where the `package_group` is defined. Fixes an issue where bazel build would fail when a `package_group` referenced an external repository in its `packages` attribute. ### Build API Changes Yes. This change affects the behavior of the `package_group` rule and the `visibility()` function in `.bzl` files. 1. Has this been discussed in a design doc or issue? No, but the change and impact should be straightforward to understand. 2. Is the change backward compatible? Yes, it relaxes a restriction that previously caused errors. 3. If it's a breaking change, what is the migration plan? N/A ### Checklist - [x] I have added tests for the new use cases (if any). - [ ] I have updated the documentation (if applicable). ### Release Notes RELNOTES: `package_group` now supports labels with external repositories in the `packages` attribute. Closes bazelbuild#28811. PiperOrigin-RevId: 878957471 Change-Id: Ic84df870374fb8c6f6f24d6fdff388d909750469
meteorcloudy
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR enables
package_groupto correctly interpret labels that include external repositories (e.g.,@module//...or@module//:__subpackages__).Motivation
Previously,
PackageSpecification.javastrictly required package names to start with//, failing on labels with repository prefixes. This made it impossible to define apackage_groupthat includes packages from other Bzlmod modules. This change leveragesLabel.parseWithRepoContextto correctly resolve repository mapping and validate package specifications within the context of the repository where thepackage_groupis defined.Fixes an issue where bazel build would fail when a
package_groupreferenced an external repository in itspackagesattribute.Build API Changes
Yes. This change affects the behavior of the
package_grouprule and thevisibility()function in.bzlfiles.Checklist
Release Notes
RELNOTES:
package_groupnow supports labels with external repositories in thepackagesattribute.Closes #28811.
PiperOrigin-RevId: 878957471
Change-Id: Ic84df870374fb8c6f6f24d6fdff388d909750469
Commit dfe9326