Skip to content

Add reproducer for #441: package_group change not detected as impacted (false negative)#442

Merged
tinder-maxwellelliott merged 1 commit into
masterfrom
claude/reproducer-issue-441
Jul 22, 2026
Merged

Add reproducer for #441: package_group change not detected as impacted (false negative)#442
tinder-maxwellelliott merged 1 commit into
masterfrom
claude/reproducer-issue-441

Conversation

@tinder-maxwellelliott

Copy link
Copy Markdown
Collaborator

What

Reproducer test for the under-invalidation (false-negative) half of #441.

bazel-diff only keeps targets whose query Discriminator is RULE, SOURCE_FILE, or GENERATED_FILE; every other type is dropped by BazelQueryService.toBazelTarget (it 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.

As #441 puts it:

Bazel's query proto represented the package-group change, but bazel-diff v35.0.0 discarded it as an unsupported target type … v35.0.0 reported no impacted targets.

Reproducer

New fixture workspace cli/src/test/resources/workspaces/package_group_dropped/:

  • //lib:consumers — a package_group created by a macro in lib/defs.bzl, gating the visibility of //lib:thing. Its allow-list lives in defs.bzl as ALLOWED.
  • //lib:thing — a genrule declared directly (not via the macro), so its per-rule .bzl seed never picks up defs.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 ALLOWED in lib/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_GROUP target.

New E2E test testPackageGroupChangeIsNotImpacted_reproducerForIssue441 asserts the current (buggy) behaviour: zero impacted targets.

Verified against real Bazel (8.5.1)

Workspace A (ALLOWED = ["//consumer"]) Workspace B (ALLOWED = [])
bazel build //consumer:use_thing ✅ builds target '//lib:thing' is not visible from //consumer:use_thing
bazel-diff get-impacted-targets ∅ (nothing reported)

A 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_GROUP targets and their reverse-visibility dependents), the changed package_group and/or //consumer:use_thing should start appearing and this assertion will flag the change.

Refs #441.

🤖 Generated with Claude Code

…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>
@tinder-maxwellelliott
tinder-maxwellelliott merged commit 81d9e41 into master Jul 22, 2026
15 checks passed
@tinder-maxwellelliott
tinder-maxwellelliott deleted the claude/reproducer-issue-441 branch July 22, 2026 16:00
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.

1 participant