Adding checks for empty metadata and digest.
This will avoid the uninformative NullPointerException for this case The underlying cause is data dependency on directories, which we want to disable. In the future, it will be allowed, but in a more explicit form (e.g. trailing slash).
TESTED=no
RELNOTES: None
@@ -16,6 +16,7 @@ package com.google.devtools.build.lib.remote;
import static java.nio.charset.StandardCharsets.UTF_8;
+import com.google.common.base.Preconditions;
import com.google.common.hash.HashCode;
import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.MetadataProvider;
@@ -105,6 +106,11 @@ public final class Digests {
public static Digest getDigestFromInputCache(ActionInput input, MetadataProvider cache)
throws IOException {
Metadata metadata = cache.getMetadata(input);
+ Preconditions.checkNotNull(metadata, "Input cache %s returned no value for %s", cache, input);
+ Preconditions.checkNotNull(
+ metadata.getDigest(),
+ "Null digest for %s, possible directory. Data dependencies on directories are not allowed.",
+ input);
return buildDigest(metadata.getDigest(), metadata.getSize());
}
}
