Skip to content

Commit 48fa3df

Browse files
authored
Update AbstractActionInputPrefetcher.java
The downloads in AbstractActionInputPrefetcher#prefetchInputs reported lost inputs that are symlinks to other artifacts with the exec path of the target, which results in a crash when the target is not also an input to the action. This is fixed by always reporting the exec path of the symlink. Fixes bazelbuild#25841
1 parent c0c98a2 commit 48fa3df

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java

+19-8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.google.devtools.build.lib.events.Reporter;
4848
import com.google.devtools.build.lib.profiler.Profiler;
4949
import com.google.devtools.build.lib.profiler.ProfilerTask;
50+
import com.google.devtools.build.lib.remote.common.CacheNotFoundException;
5051
import com.google.devtools.build.lib.remote.util.AsyncTaskCache;
5152
import com.google.devtools.build.lib.util.TempPathGenerator;
5253
import com.google.devtools.build.lib.vfs.FileSymlinkLoopException;
@@ -394,14 +395,24 @@ private ListenableFuture<Void> prefetchFile(
394395

395396
Completable result =
396397
downloadFileNoCheckRx(
397-
action,
398-
execRoot.getRelative(execPath),
399-
treeRootExecPath != null ? execRoot.getRelative(treeRootExecPath) : null,
400-
dirsWithOutputPermissions,
401-
input,
402-
metadata,
403-
priority,
404-
reason);
398+
action,
399+
execRoot.getRelative(execPath),
400+
treeRootExecPath != null ? execRoot.getRelative(treeRootExecPath) : null,
401+
dirsWithOutputPermissions,
402+
input,
403+
metadata,
404+
priority,
405+
reason)
406+
.onErrorResumeNext(
407+
t -> {
408+
if (t instanceof CacheNotFoundException cacheNotFoundException) {
409+
// Only the symlink itself is guaranteed to be an input to the action, so
410+
// report its path for rewinding.
411+
cacheNotFoundException.setExecPath(input.getExecPath());
412+
return Completable.error(cacheNotFoundException);
413+
}
414+
return Completable.error(t);
415+
});
405416

406417
if (symlink != null) {
407418
result = result.andThen(plantSymlink(symlink));

0 commit comments

Comments
 (0)