From 5e9fa3967cf0288083638aec3b34328ab8a90a51 Mon Sep 17 00:00:00 2001 From: John Cater Date: Tue, 18 Apr 2023 16:38:39 -0400 Subject: [PATCH] Add attribute validation to IncompatibleTargetChecker. (#18135) This causes errors with configurable `target_compatible_with` to be reported as errors, rather than causing a Bazel crash. Fixes bazelbuild#18021. (This is functionally the same change as ebfb529a78978c3cfd1d93141c7762f908698df9, but applied to the release-6.2.0 branch) --- .../IncompatibleTargetChecker.java | 4 +-- .../packages/ConfiguredAttributeMapper.java | 2 +- .../google/devtools/build/lib/skyframe/BUILD | 1 + .../skyframe/ConfiguredTargetFunction.java | 31 ++++++++++++++----- .../target_compatible_with_test.sh | 27 ++++++++++++++++ 5 files changed, 55 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/constraints/IncompatibleTargetChecker.java b/src/main/java/com/google/devtools/build/lib/analysis/constraints/IncompatibleTargetChecker.java index 2f4bb040daf303..23bb7ddbedaeba 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/constraints/IncompatibleTargetChecker.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/constraints/IncompatibleTargetChecker.java @@ -107,7 +107,7 @@ public static Optional createDirectlyIncompatibleTarg Environment env, @Nullable PlatformInfo platformInfo, NestedSetBuilder transitivePackages) - throws InterruptedException { + throws ConfiguredAttributeMapper.ValidationException, InterruptedException { Target target = targetAndConfiguration.getTarget(); Rule rule = target.getAssociatedRule(); @@ -124,7 +124,7 @@ public static Optional createDirectlyIncompatibleTarg } // Resolve the constraint labels. - List