Commit 1f737d4
committed
Fix query-failure fallback for bzlmod-only workspaces
The per-repo rdeps query-failure fallback filtered out every `@@` label
on the assumption that the hash set was mostly workspace-local `//...`
targets. That assumption does not hold on bzlmod-only workspaces where
`generate-hashes` emits almost entirely `@@canonical` labels plus a
small number of `//external:<apparent>` bzlmod-synthetic bridges, with
zero workspace-local targets.
On such workspaces, a single failed `rdeps(//..., @@<repo>//...)` query
(for example, one caused by an unrelated loading error elsewhere in the
dep graph) left the filter with only the `//external:*` bridges, which
the downstream `excludeExternalTargets=true` default (Tinder#334) then strips
entirely — producing silently-empty impacted output on what should be a
"conservatively rebuild everything" signal.
Replace the unconditional `!startsWith("@@")` filter with a shape-aware
fallback:
- Compute a "buildable workspace" set that excludes BOTH `@@canonical`
transitives AND `//external:<apparent>` bridges.
- If that set is non-empty (mixed WORKSPACE + bzlmod, or WORKSPACE-only
shapes), emit it — preserves pre-existing granularity, avoids leaking
tens of thousands of `@@` transitives into the impacted set on a
single flaky `bazel query`.
- If it is empty (bzlmod-only shape), fall through to `allTargets.keys`
so the downstream filter has something to keep — rebuild-everything
signal rather than a directly-buildable label list.
Adds a mixed-shape regression test asserting that `@@` transitives and
`//external:*` bridges do NOT leak into the fallback when buildable
workspace labels are present, complementing the existing bzlmod-only
test. An unconditional `allTargets.keys` fallback fails the new test;
the pre-commit `!startsWith("@@")` filter fails the existing bzlmod-only
one. Only the shape-aware fallback passes both.1 parent a61697d commit 1f737d4
2 files changed
Lines changed: 71 additions & 1 deletion
File tree
- cli/src
- main/kotlin/com/bazel_diff/interactor
- test/kotlin/com/bazel_diff/interactor
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
378 | 388 | | |
379 | 389 | | |
380 | 390 | | |
| |||
cli/src/test/kotlin/com/bazel_diff/interactor/CalculateImpactedTargetsInteractorModuleQueryTest.kt
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
315 | 375 | | |
316 | 376 | | |
317 | 377 | | |
| |||
0 commit comments