Skip to content

Fix #612: main-repository aliases dropped under --useCquery - #617

Merged
tinder-maxwellelliott merged 2 commits into
masterfrom
claude/reproducer-issue-612
Nov 3, 2026
Merged

tinder-maxwellelliott merged 2 commits into
masterfrom
claude/reproducer-issue-612

Conversation

@tinder-maxwellelliott

Copy link
Copy Markdown
Collaborator

Fixes #612.

Reproducer

New fixture tests/resources/workspaces/cquery_main_repo_alias: a genrule //:wrapper whose only srcs entry is //:tool, an alias of //bar:baz (a filegroup over bar/baz.txt). Two e2e cases in tests/e2e/regressions.rs change bar/baz.txt between two copies of the workspace:

  • main_repo_alias_change_reaches_consumer_query is the query-mode control. It passes on master.
  • main_repo_alias_change_reaches_consumer_cquery runs with --useCquery and asserts that @@//:tool is in the hashes, that @@//:wrapper has a dep edge to it, and that //:wrapper is impacted. On master (Bazel 8.8.2) it fails on the first assertion: the hash file has no //:tool entry at all, matching the report.

Fix

The compatible-target cquery in query_compatible_labels names an alias by repr(target). Bazel prints a main-repository alias with its apparent label (//:tool) even under --consistent_labels, while every other target comes back canonical (@@//:tool). The compatible set never contained the alias's canonical label, so the alias was filtered out as if it were platform-incompatible and every edge through it went with it. The Starlark formatter now prefixes @@ to apparent main-repository labels, as suggested in the issue.

Verification

With the fix, the new cquery case passes, and the existing cquery cases (cquery_keeps_dependencies_of_every_configured_instance, hidden_wrapper_external_repo_change_reaches_main_consumer_cquery, single_version_override_patch_change_reaches_consumer_cquery, extension_repo_patch_edit_impacts_toolchain_user_cquery, external::fine_grained_bzlmod_repo_cquery) and //src/... unit tests still pass locally.

The reproducer and the fix are separate commits, so the first commit alone shows the failure.

🤖 Generated with Claude Code

tinder-maxwellelliott and others added 2 commits November 3, 2026 14:25
Adds the cquery_main_repo_alias fixture (a genrule whose only src is an
alias of a filegroup in another package) and two e2e cases. The query-mode
control passes; the cquery case fails on master because the
compatible-target cquery names the alias by repr(target), which Bazel
prints as the apparent label //:tool while the target is named @@//:tool,
so the alias is filtered out as if it were platform-incompatible and
//:wrapper loses its edge through it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…target cquery

The compatible-target cquery names an alias by repr(target), and Bazel
prints a main-repository alias with its apparent label (//:tool) even
under --consistent_labels, while every other target is canonical
(@@//:tool). The compatible set therefore never contained the alias's
canonical label and query_compatible_labels filtered it out as if it were
platform-incompatible, dropping every edge through it. Prefix @@ to
apparent main-repository labels so the alias matches.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@tinder-maxwellelliott
tinder-maxwellelliott merged commit 50934ca into master Nov 3, 2026
19 checks passed
@tinder-maxwellelliott
tinder-maxwellelliott deleted the claude/reproducer-issue-612 branch November 3, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In cquery mode, main-repository aliases are dropped, and so is every edge through them

1 participant