Making sure the digest on the FileOutputSymlink does not lose all of it's data when being passed down the pipeline

RELNOTES: None.
PiperOrigin-RevId: 269429764
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java
index 348fc02..3ada580 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java
@@ -362,8 +362,10 @@
       return new HasDigest.ByteStringDigest(
           ((FileStateValue) fsVal).getValueFingerprint().toByteArray());
     } else if (fsVal instanceof FileArtifactValue) {
-      return new HasDigest.ByteStringDigest(
-          ((FileArtifactValue) fsVal).getValueFingerprint().toByteArray());
+      FileArtifactValue artifactValue = (FileArtifactValue) fsVal;
+      // Transforming the FileArtifactValue to fingerprint the digests and retain other values
+      return FileArtifactValue.createForVirtualActionInput(
+          artifactValue.getValueFingerprint().toByteArray(), artifactValue.getSize());
     }
     return fsVal;
   }
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java
index dde3e82..09e8005 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java
@@ -1066,6 +1066,30 @@
     }
   }
 
+  @Test
+  public void testFileArtifactValueRetainsData() throws Exception {
+    Artifact artifact = derivedArtifact("foo/fooy.txt");
+    Artifact strictArtifact = derivedArtifact("goo/gooy.txt");
+    createFile(rootedPath(artifact), "fooy");
+    createFile(rootedPath(strictArtifact), "gooy");
+    TraversalRequest request = fileLikeRoot(artifact, DONT_CROSS, false);
+    TraversalRequest strictRequest = fileLikeRoot(strictArtifact, DONT_CROSS, true);
+
+    EvaluationResult<RecursiveFilesystemTraversalValue> result = eval(request);
+    EvaluationResult<RecursiveFilesystemTraversalValue> strictResult = eval(strictRequest);
+
+    assertThat(result.values()).hasSize(1);
+    assertThat(strictResult.values()).hasSize(1);
+
+    RecursiveFilesystemTraversalValue value = result.values().iterator().next();
+    RecursiveFilesystemTraversalValue strictValue = strictResult.values().iterator().next();
+    ResolvedFile resolvedFile = value.getResolvedRoot().get();
+    ResolvedFile strictResolvedFile = strictValue.getResolvedRoot().get();
+
+    assertThat(resolvedFile.getMetadata()).isInstanceOf(FileArtifactValue.class);
+    assertThat(strictResolvedFile.getMetadata()).isInstanceOf(FileArtifactValue.class);
+  }
+
   private static class NonHermeticArtifactSkyKey extends AbstractSkyKey<SkyKey> {
     private NonHermeticArtifactSkyKey(SkyKey arg) {
       super(arg);