From 763f966af5ebc6d3bdf97feb150ebace6a2cebd2 Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 2 Jan 2023 02:47:48 -0800 Subject: [PATCH] Enforce that none of the inputs passed to prefetchFiles are directories. This precondition should hold today (otherwise we'd later attempt to prefetch the directory as it if were a file and fail), but this change makes the ensuing crash a little more obvious. PiperOrigin-RevId: 498997318 Change-Id: I7f8df36c56b969c939f42e2d937a21be39520f23 --- .../build/lib/remote/AbstractActionInputPrefetcher.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java b/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java index 9590f2c57cfa5a..234172c0ecfd6a 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java +++ b/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.remote; +import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import static com.google.common.util.concurrent.MoreExecutors.directExecutor; import static com.google.devtools.build.lib.remote.util.RxFutures.toCompletable; @@ -158,6 +159,8 @@ protected Completable onErrorResumeNext(Throwable error) { * Fetches remotely stored action outputs, that are inputs to this spawn, and stores them under * their path in the output base. * + *

The {@code inputs} may not contain any unexpanded directories. + * *

This method is safe to be called concurrently from spawn runners before running any local * spawn. * @@ -176,6 +179,9 @@ protected ListenableFuture prefetchFiles( Map> trees = new HashMap<>(); List files = new ArrayList<>(); for (ActionInput input : inputs) { + checkArgument(!input.isDirectory(), "cannot prefetch a directory"); + + // Source artifacts don't need to be fetched. if (input instanceof Artifact && ((Artifact) input).isSourceArtifact()) { continue; }