diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionValue.java index 73c047ebc50650..50a9ee2ca59827 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionValue.java @@ -79,9 +79,7 @@ private ActionExecutionValue( } for (Map.Entry file : treeArtifact.getChildValues().entrySet()) { - // We should only have RegularFileValue instances in here, but apparently tree artifacts - // sometimes store their own root directory in here. Sad. - // https://github.com/bazelbuild/bazel/issues/9058 + // Tree artifacts can contain symlinks to directories, which don't have a digest. if (file.getValue().getType().isFile()) { Preconditions.checkNotNull( file.getValue().getDigest(), diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactBuildTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactBuildTest.java index c2a2bbf596cfac..4ace8b7c93c212 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactBuildTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactBuildTest.java @@ -833,6 +833,28 @@ public void emptyInputAndOutputTreeArtifactInActionTemplate() throws Exception { assertThat(artifact2.getPath().getDirectoryEntries()).isEmpty(); } + // This happens in the wild. See https://github.com/bazelbuild/bazel/issues/11813. + @Test + public void treeArtifactContainsSymlinkToDirectory() throws Exception { + SpecialArtifact treeArtifact = createTreeArtifact("tree"); + registerAction( + new SimpleTestAction(/*output=*/ treeArtifact) { + @Override + void run(ActionExecutionContext context) throws IOException { + PathFragment subdir = PathFragment.create("subdir"); + touchFile(treeArtifact.getPath().getRelative(subdir).getRelative("file")); + treeArtifact.getPath().getRelative("link").createSymbolicLink(subdir); + } + }); + + TreeArtifactValue tree = buildArtifact(treeArtifact); + + assertThat(tree.getChildren()) + .containsExactly( + TreeFileArtifact.createTreeOutput(treeArtifact, "subdir/file"), + TreeFileArtifact.createTreeOutput(treeArtifact, "link")); + } + private abstract static class SimpleTestAction extends TestAction { private final Button button;