From 9e7e592ca51eba1a3f120320c41c845312894d74 Mon Sep 17 00:00:00 2001 From: chiwang Date: Tue, 20 Apr 2021 09:00:40 -0700 Subject: [PATCH] Remote: Check the return value of ActionOwner.getLabel() since it could be `null`. Fixes https://github.com/bazelbuild/bazel/issues/13368. Closes #13369. PiperOrigin-RevId: 369451029 --- .../java/com/google/devtools/build/lib/remote/util/BUILD | 1 + .../build/lib/remote/util/TracingMetadataUtils.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/remote/util/BUILD b/src/main/java/com/google/devtools/build/lib/remote/util/BUILD index 22134fa44a79eb..9afc158cfbad38 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/util/BUILD +++ b/src/main/java/com/google/devtools/build/lib/remote/util/BUILD @@ -19,6 +19,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/actions:execution_requirements", "//src/main/java/com/google/devtools/build/lib/analysis:blaze_version_info", "//src/main/java/com/google/devtools/build/lib/authandtls", + "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/remote:ExecutionStatusException", "//src/main/java/com/google/devtools/build/lib/remote/common", "//src/main/java/com/google/devtools/build/lib/remote/options", diff --git a/src/main/java/com/google/devtools/build/lib/remote/util/TracingMetadataUtils.java b/src/main/java/com/google/devtools/build/lib/remote/util/TracingMetadataUtils.java index 557973832636f3..e4f81fc38dce19 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/util/TracingMetadataUtils.java +++ b/src/main/java/com/google/devtools/build/lib/remote/util/TracingMetadataUtils.java @@ -19,6 +19,7 @@ import com.google.common.base.Preconditions; import com.google.devtools.build.lib.actions.ActionExecutionMetadata; import com.google.devtools.build.lib.analysis.BlazeVersionInfo; +import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.remote.options.RemoteOptions; import io.grpc.ClientInterceptor; import io.grpc.Context; @@ -65,7 +66,10 @@ public static RequestMetadata buildMetadata( .setToolVersion(BlazeVersionInfo.instance().getVersion())); if (actionMetadata != null) { builder.setActionMnemonic(actionMetadata.getMnemonic()); - builder.setTargetId(actionMetadata.getOwner().getLabel().getCanonicalForm()); + Label label = actionMetadata.getOwner().getLabel(); + if (label != null) { + builder.setTargetId(label.getCanonicalForm()); + } builder.setConfigurationId(actionMetadata.getOwner().getConfigurationChecksum()); } return builder.build();