Skip to content

Conversation

@timothyg-stripe
Copy link
Contributor

@timothyg-stripe timothyg-stripe commented Jan 9, 2026

This PR reimplements #27242 in terms of BzlmodRepoRuleValue for Bazel 8.x, as 8.x doesn't include #26493.


Serialize repo definitions to a new Repository proto message.

A few more notable details:

  • Similar to the original Starlark output, the same (canonical) repo can be shown multiple times if the user explicitly specified the same repo in different ways:

    ❯ bazel-bin/src/bazel_nojdk mod show_repo @@rules_cc+ @rules_cc rules_cc
    ## @@rules_cc+:
    http_archive(
      name = "rules_cc+",
      ...
    ## @rules_cc:
    http_archive(
      name = "rules_cc+",
      ...
    ## [email protected]:
    http_archive(
      name = "rules_cc+",
      ...
    ❯ bazel-bin/src/bazel_nojdk mod show_repo --output=streamed_jsonproto @@rules_cc+ @rules_cc rules_cc
    {"canonicalName":"rules_cc+", 
    {"canonicalName":"rules_cc+","apparentName":"@rules_cc", 
    {"canonicalName":"rules_cc+","moduleKey":"[email protected]",
  • Tighten up command argument validation so that bazel mod show_{repo,extension} --output={graph,json} now exits with an error, addressing a common source of user confusion. I decided not to add the same validation to all bazel mod subcommands since no one can possibly expect bazel mod tidy --output=graph to do something.

Fixes #21617.

Works towards #24692.

Closes #27242.

Fixes #28009.

…ut=streamed_jsonproto`

Serialize repo definitions to the same `Target` proto that `bazel query` uses.

A few more notable details:

*   Add back `_original_name`, even to the Starlark output. This was removed in bazelbuild#26493, but I believe it's still useful for debugging.

*   The output protos may contain a `$apparent_repo_name` or `$module_key` pseudo-attribute, which is the equivalent of the `## @repo_name` / `## module@version` line in the Starlark output.

*   Similar to the original Starlark output, the same (canonical) repo can be shown multiple times if the user explicitly specified the same repo in different ways:

    ```sh
    ❯ bazel-bin/src/bazel_nojdk mod show_repo @@rules_cc+ @rules_cc rules_cc
    ```
    ```starlark
    ## @@rules_cc+:
    http_archive(
      name = "rules_cc+",
      ...
    ## @rules_cc:
    http_archive(
      name = "rules_cc+",
      ...
    ## [email protected]:
    http_archive(
      name = "rules_cc+",
      ...
    ```

    ```sh
    ❯ bazel-bin/src/bazel_nojdk mod show_repo --output=streamed_jsonproto @@rules_cc+ @rules_cc rules_cc
    ```
    ```js
    {"canonicalName":"rules_cc+", …
    {"canonicalName":"rules_cc+","apparentName":"@rules_cc", …
    {"canonicalName":"rules_cc+","moduleKey":"[email protected]", …
    ```

*   Tighten up command argument validation so that `bazel mod show_{repo,extension} --output={graph,json}` now exits with an error, addressing a common source of user confusion. I decided not to add the same validation to all `bazel mod` subcommands since no one can possibly expect `bazel mod tidy --output=graph` to do something.

Fixes bazelbuild#21617.

Works towards bazelbuild#24692.

Closes bazelbuild#27242.
This reverts commit 69970f1.
@timothyg-stripe timothyg-stripe requested a review from a team as a code owner January 9, 2026 20:37
@github-actions github-actions bot added team-Performance Issues for Performance teams team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Documentation Documentation improvements that cannot be directly linked to other team labels awaiting-review PR is awaiting review from an assigned reviewer labels Jan 9, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new protobuf-based output formats for bazel mod show_repo and enhances argument validation for several mod subcommands. The changes are well-implemented, with corresponding updates to documentation and tests. My review focuses on improving the robustness of I/O operations. I've pointed out a couple of instances where IOExceptions are silently ignored, which could result in incomplete output without notifying the user. I've suggested handling these exceptions to ensure more reliable behavior.

aspectResolver.computeAspectDependencies(target, dependencyFilter);
ImmutableMap.of();
if (aspectResolver != null) {
aspectsDependencies = aspectResolver.computeAspectDependencies(target, dependencyFilter);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's already a null check for aspectResolver elsewhere in the file, so I thought this is warranted:

aspectResolver == null
? inputFile.getPackage().getOrComputeTransitivelyLoadedStarlarkFiles()
: aspectResolver.computeBuildFileDependencies(inputFile.getPackage());

@Wyverald Wyverald enabled auto-merge January 9, 2026 20:45
@Wyverald Wyverald added this pull request to the merge queue Jan 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2026
@iancha1992 iancha1992 added this pull request to the merge queue Jan 9, 2026
Merged via the queue into bazelbuild:release-8.6.0 with commit a1370e4 Jan 9, 2026
47 checks passed
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jan 9, 2026
@timothyg-stripe timothyg-stripe deleted the mod-cherry-picks-8 branch January 9, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Documentation Documentation improvements that cannot be directly linked to other team labels team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Performance Issues for Performance teams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants