Skip to content

Commit 8e552b0

Browse files
fmeumcopybara-github
authored andcommitted
Add configuration short ID to analysis error
This makes it possible to debug config-dependent errors. Closes #26690. PiperOrigin-RevId: 792275177 Change-Id: I026d6aae8a3dbc1da20a155f4b873d0349b76a8d
1 parent 1e9b233 commit 8e552b0

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,11 @@ private AspectValue createAspect(
10171017
events.replayOn(env.getListener());
10181018
if (events.hasErrors()) {
10191019
analysisEnvironment.disable(associatedTarget);
1020-
String msg = "Analysis of target '" + associatedTarget.getLabel() + "' failed";
1020+
String msg =
1021+
"Analysis of target '%s' (config: %s) failed"
1022+
.formatted(
1023+
associatedTarget.getLabel(),
1024+
configuration != null ? configuration.getOptions().shortId() : "none");
10211025
throw new AspectFunctionException(
10221026
new AspectCreationException(msg, key.getLabel(), configuration));
10231027
}

src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
3232
import com.google.devtools.build.lib.analysis.ConfiguredTargetValue;
3333
import com.google.devtools.build.lib.analysis.DependencyKind;
34+
import com.google.devtools.build.lib.analysis.DependencyResolutionHelpers;
3435
import com.google.devtools.build.lib.analysis.ExecGroupCollection;
3536
import com.google.devtools.build.lib.analysis.ExecGroupCollection.InvalidExecGroupException;
3637
import com.google.devtools.build.lib.analysis.FilesToRunProvider;
@@ -491,7 +492,10 @@ private static ConfiguredTargetValue createConfiguredTarget(
491492
throw new ConfiguredValueCreationException(
492493
ctgValue.getTarget(),
493494
null,
494-
"Analysis of target '" + target.getLabel() + "' failed",
495+
"Analysis of target '%s' (config: %s) failed"
496+
.formatted(
497+
target.getLabel(),
498+
configuration != null ? configuration.getOptions().shortId() : "none"),
495499
rootCauses,
496500
null);
497501
}

src/test/java/com/google/devtools/build/lib/buildtool/OutputArtifactConflictTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,8 @@ def _aspect_impl(target, ctx):
557557
events.assertContainsError("/bin/x/y/whatever' (belonging to //x/y:y)");
558558
events.assertContainsError("/bin/x/y' (belonging to //x:y)");
559559
events.assertContainsError("is a prefix of the other");
560-
events.assertContainsError("Analysis of target '//x:fail_analysis' failed");
560+
events.assertContainsError("Analysis of target '//x:fail_analysis' (config: ");
561+
events.assertContainsError(") failed");
561562

562563
assertThat(eventListener.analysisFailures).containsAtLeast("//x:y", "//x:fail_analysis");
563564
} else if (minimizeMemory) {

0 commit comments

Comments
 (0)