Skip to content

Fix #268 InvalidDependencyEdgesException now warns + reports distance 0#341

Merged
tinder-maxwellelliott merged 2 commits into
masterfrom
claude/reproducer-issue-268
May 13, 2026
Merged

Fix #268 InvalidDependencyEdgesException now warns + reports distance 0#341
tinder-maxwellelliott merged 2 commits into
masterfrom
claude/reproducer-issue-268

Conversation

@tinder-maxwellelliott
Copy link
Copy Markdown
Collaborator

@tinder-maxwellelliott tinder-maxwellelliott commented May 12, 2026

Summary

Fixes #268.

Root cause. Users who pass --targetType=Rule to generate-hashes end up with hash JSONs that only contain Rule entries — SourceFile and GeneratedFile rows are stripped at write time. When that JSON was fed back into get-impacted-targets --depsFile=... (which routes through executeWithDistancescomputeAllDistances), an indirectly impacted Rule whose only changed dep was a filtered-out GeneratedFile triggered:

InvalidDependencyEdgesException("<label> was indirectly impacted, but has no impacted dependencies.")

and crashed the whole job. @agustinmista narrowed the cause to exactly this combination in the issue thread.

Fix. Both throw InvalidDependencyEdgesException(...) sites in CalculateImpactedTargetsInteractor.calculateDistance are replaced with a logger.w() that points at --targetType as the most likely cause, plus a return of TargetDistanceMetrics(0, 0). The indirectly impacted target still appears in the impacted-targets output rather than crashing the run.

Two code paths now warn-and-fallback instead of throw:

  • The target has no entry in the dep-edges file at all.
  • The target has dep-edges entries, but none of those deps are themselves in the impacted-labels map.

The previously-thrown @VisibleForTesting nested class InvalidDependencyEdgesException is no longer referenced, so it's removed along with its (now unused) com.google.common.annotations.VisibleForTesting import.

Tests. testInvalidEdgesRaises becomes testInvalidEdgesFallsBackToDistanceZero and now asserts both fallback paths return distance 0. The reproducer added in the first commit on this branch loses its @Ignore and is renamed to a regression test — it sets up the exact --targetType=Rule + GeneratedFile-in-depEdges-but-not-in-hashes scenario from the issue and asserts the call succeeds with //pkg:rule reported at distance 0.

Test plan

  • bazel build //cli:cli-test-lib — clean.
  • bazel test //cli:CalculateImpactedTargetsInteractorTest --cache_test_results=noPASSED in 1.3s (all tests in the class, including the un-@Ignored reproducer and the rewritten testInvalidEdgesFallsBackToDistanceZero).
  • Full unit-test sweep across all 12 kt_jvm_test targets → all 12 PASSED.

🤖 Generated with Claude Code

tinder-maxwellelliott and others added 2 commits May 12, 2026 17:07
…argetType

Users who pass `--targetType=Rule` to `generate-hashes` end up with hash
JSONs that only contain Rule entries -- SourceFile and GeneratedFile rows
are stripped at write time. When that JSON is fed back into
`get-impacted-targets --depsFile=...` (which routes through
`executeWithDistances` -> `computeAllDistances`), an indirectly impacted
Rule whose only changed dependency is a filtered-out GeneratedFile
triggers:

  InvalidDependencyEdgesException("<label> was indirectly impacted, but has no impacted dependencies.")

The whole job crashes. The user in #268 narrowed the cause to exactly this
combination: `--targetType=Rule` plus a Rule that depends on a
GeneratedFile in their autogenerated graph. The asked-for fix is to
downgrade this to a warning (with a conservative distance like 0) so the
indirectly impacted Rule still appears in the impacted-targets output
instead of taking the whole CI down.

This adds a @ignore'd unit reproducer that asserts computeAllDistances
does not throw and the Rule still appears in the result. Drop the @ignore
once the fix lands.

Refs #268

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Users who pass `--targetType=Rule` to `generate-hashes` end up with
hash JSONs that only contain Rule entries -- SourceFile and
GeneratedFile rows are stripped at write time. When that JSON was fed
back into `get-impacted-targets --depsFile=...` (which routes through
executeWithDistances -> computeAllDistances), an indirectly impacted
Rule whose only changed dep was a filtered-out GeneratedFile triggered:

  InvalidDependencyEdgesException("<label> was indirectly impacted, but has no impacted dependencies.")

and crashed the whole job. @agustinmista narrowed the cause to exactly
this combination in the issue thread.

Fix: replace both `throw InvalidDependencyEdgesException(...)` sites in
CalculateImpactedTargetsInteractor.calculateDistance with a logger.w()
that points at --targetType as the most likely cause, and return
TargetDistanceMetrics(0, 0). The indirectly impacted target still
appears in the impacted-targets output rather than crashing the run.

Two code paths now warn-and-fallback instead of throw:
  - The target has no entry in the dep-edges file at all.
  - The target has dep-edges entries, but none of those deps are
    themselves in the impacted-labels map.

The previously-thrown @VisibleForTesting nested class
`InvalidDependencyEdgesException` is no longer referenced; removed
along with its (now unused) `com.google.common.annotations.VisibleForTesting`
import.

testInvalidEdgesRaises updated and renamed to
testInvalidEdgesFallsBackToDistanceZero -- it now asserts both fallback
paths return distance 0. The reproducer (added in the previous commit)
loses its @ignore and is renamed to a regression test.

Refs #268

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tinder-maxwellelliott tinder-maxwellelliott force-pushed the claude/reproducer-issue-268 branch from 1975f8c to 49b9663 Compare May 12, 2026 21:10
@tinder-maxwellelliott tinder-maxwellelliott changed the title Reproducer test for #268 InvalidDependencyEdgesException with --targetType Fix #268 InvalidDependencyEdgesException now warns + reports distance 0 May 12, 2026
@tinder-maxwellelliott tinder-maxwellelliott merged commit 0a53be0 into master May 13, 2026
15 checks passed
@tinder-maxwellelliott tinder-maxwellelliott deleted the claude/reproducer-issue-268 branch May 13, 2026 14:03
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.

Target was indirectly impacted, but has no impacted dependencies

1 participant