Add reproducer for #441: package_group change not detected as impacted (false negative)#442
Merged
Merged
Conversation
…cted bazel-diff only keeps targets whose query Discriminator is RULE, SOURCE_FILE, or GENERATED_FILE; every other type is dropped by BazelQueryService.toBazelTarget (logs "Unsupported target type" and returns null). PACKAGE_GROUP is one such dropped type, so a change to a package_group's `packages` list is never reflected in any hash -- even though it genuinely alters downstream visibility and can flip a consumer from building to failing. This is the under-invalidation (false-negative) half of issue #441. New E2E test testPackageGroupChangeIsNotImpacted_reproducerForIssue441 and fixture workspace package_group_dropped: - //lib:consumers is a package_group (created by a macro in lib/defs.bzl) gating the visibility of //lib:thing; its allow-list lives in defs.bzl. - //lib:thing is a genrule declared directly (not via the macro) so its per-rule .bzl seed never picks up defs.bzl, isolating this bug from the separate .bzl-provenance (over-invalidation) half of #441. - //consumer:use_thing depends on //lib:thing. The only change between the two checkouts empties ALLOWED in lib/defs.bzl, revoking //consumer's visibility of //lib:thing. Verified against real Bazel 8.5.1: workspace A builds //consumer:use_thing successfully while workspace B fails visibility analysis, yet bazel-diff reports ZERO impacted targets. The test pins that current (buggy) behaviour; when the under-invalidation is fixed (e.g. by supporting PACKAGE_GROUP targets and their reverse-visibility dependents) the assertion will flag the change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Reproducer test for the under-invalidation (false-negative) half of #441.
bazel-diff only keeps targets whose query
DiscriminatorisRULE,SOURCE_FILE, orGENERATED_FILE; every other type is dropped byBazelQueryService.toBazelTarget(it logs"Unsupported target type"and returnsnull).PACKAGE_GROUPis one such dropped type, so a change to apackage_group'spackageslist is never reflected in any hash — even though it genuinely alters downstream visibility and can flip a consumer from building to failing.As #441 puts it:
Reproducer
New fixture workspace
cli/src/test/resources/workspaces/package_group_dropped/://lib:consumers— apackage_groupcreated by a macro inlib/defs.bzl, gating the visibility of//lib:thing. Its allow-list lives indefs.bzlasALLOWED.//lib:thing— a genrule declared directly (not via the macro), so its per-rule.bzlseed never picks updefs.bzl. This isolates this bug from the separate.bzl-provenance (over-invalidation) half of Distinguish macro source changes from changes to Bazel's loaded package state #441.//consumer:use_thing— depends on//lib:thing.The only change between the two checkouts empties
ALLOWEDinlib/defs.bzl, revoking//consumer's visibility of//lib:thing. The BUILD files and every native rule are byte-for-byte identical across the checkouts, so the sole semantic change rides entirely on the (dropped)PACKAGE_GROUPtarget.New E2E test
testPackageGroupChangeIsNotImpacted_reproducerForIssue441asserts the current (buggy) behaviour: zero impacted targets.Verified against real Bazel (8.5.1)
ALLOWED = ["//consumer"])ALLOWED = [])bazel build //consumer:use_thingtarget '//lib:thing' is not visible from //consumer:use_thingget-impacted-targetsA change that flips a real build from success to failure is completely invisible to bazel-diff.
Scope
This is a reproducer only — it pins the current behaviour so a future fix can be verified. It does not attempt the fix. The over-invalidation half of #441 (print-only macro edits marking generated native rules impacted) is a design/policy question the maintainers are still weighing, so it is intentionally left out. When the under-invalidation is fixed (e.g. by supporting
PACKAGE_GROUPtargets and their reverse-visibility dependents), the changed package_group and/or//consumer:use_thingshould start appearing and this assertion will flag the change.Refs #441.
🤖 Generated with Claude Code