Skip to content

Support external repository labels in package_group#28811

Open
meteorcloudy wants to merge 1 commit intobazelbuild:masterfrom
meteorcloudy:fix-package-group-external-repos
Open

Support external repository labels in package_group#28811
meteorcloudy wants to merge 1 commit intobazelbuild:masterfrom
meteorcloudy:fix-package-group-external-repos

Conversation

@meteorcloudy
Copy link
Member

@meteorcloudy meteorcloudy commented Feb 26, 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.

@meteorcloudy meteorcloudy requested a review from a team as a code owner February 26, 2026 10:44
@meteorcloudy meteorcloudy requested review from gregestren and removed request for a team February 26, 2026 10:44
@github-actions github-actions bot added team-Configurability platforms, toolchains, cquery, select(), config transitions awaiting-review PR is awaiting review from an assigned reviewer labels Feb 26, 2026
@meteorcloudy meteorcloudy marked this pull request as draft February 26, 2026 10:45
@meteorcloudy meteorcloudy removed the request for review from gregestren February 26, 2026 10:45
@meteorcloudy meteorcloudy force-pushed the fix-package-group-external-repos branch from 8c3b751 to 2ec99a5 Compare February 26, 2026 10:49
@meteorcloudy meteorcloudy force-pushed the fix-package-group-external-repos branch from 2ec99a5 to 2b4c509 Compare February 26, 2026 12:40
@meteorcloudy
Copy link
Member Author

@brandjon @Wyverald What do you think about this change?

@mkruskal-google needs this for limiting certain abseil targets visibility to a specific new BCR module.

     visibility = [ "@foo//bar:__subpackages__"],

already works when you have a bazel_dep on foo (assuming this dependency won't cause much problem), this change allows such declaration also in package_group.

@fmeum
Copy link
Collaborator

fmeum commented Feb 26, 2026

Does this work with nodep deps? That would resolve concerns about increased dep footprint.

@meteorcloudy
Copy link
Member Author

@fmeum Unfortunately no, nodep requires repo_name = None, so the label will be invalid. @mkruskal-google is aware of the dep footprint problem, but it should be fine for this specific case (just a standard C++ library).

@meteorcloudy
Copy link
Member Author

FYI @gregestren

@meteorcloudy meteorcloudy marked this pull request as ready for review February 27, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Configurability platforms, toolchains, cquery, select(), config transitions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants