Skip to content

[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
bazel-io:cp28811-9.0.1
Mar 5, 2026
Merged

[9.0.1] Support external repository labels in package_group (https://github.com/bazelbuild/bazel/pull/28811)#28895
meteorcloudy merged 1 commit intobazelbuild:release-9.0.1from
bazel-io:cp28811-9.0.1

Conversation

@bazel-io
Copy link
Member

@bazel-io bazel-io commented Mar 5, 2026

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

  • 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 #28811.

PiperOrigin-RevId: 878957471
Change-Id: Ic84df870374fb8c6f6f24d6fdff388d909750469

Commit dfe9326

### 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
@bazel-io bazel-io requested a review from a team as a code owner March 5, 2026 12:39
@bazel-io bazel-io added team-Configurability platforms, toolchains, cquery, select(), config transitions awaiting-review PR is awaiting review from an assigned reviewer labels Mar 5, 2026
@bazel-io bazel-io requested a review from Wyverald March 5, 2026 12:39
@bazel-io bazel-io added team-Configurability platforms, toolchains, cquery, select(), config transitions awaiting-review PR is awaiting review from an assigned reviewer labels Mar 5, 2026
@meteorcloudy meteorcloudy enabled auto-merge March 5, 2026 12:44
@meteorcloudy meteorcloudy added this pull request to the merge queue Mar 5, 2026
Merged via the queue into bazelbuild:release-9.0.1 with commit 8847a1b Mar 5, 2026
46 checks passed
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Mar 5, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants