Prevent blaze from crashing on invalid resource locations.
RELNOTES: None
@@ -286,9 +286,20 @@ public final class LocalResourceContainer {
PathFragment packageFragment =
file.getArtifactOwner().getLabel().getPackageIdentifier().getSourceRoot();
PathFragment packageRelativePath = file.getRootRelativePath().relativeTo(packageFragment);
+ try {
resourceRoots.add(
trimTail(file.getExecPath(), makeRelativeTo(resourceDir, packageRelativePath)));
-
+ } catch (IllegalArgumentException e) {
+ ruleErrorConsumer.attributeError(
+ resourcesAttr,
+ String.format(
+ "'%s' (generated by '%s') is not under the directory '%s' (derived from %s).",
+ file.getRootRelativePath(),
+ file.getArtifactOwner().getLabel(),
+ packageRelativePath,
+ file.getRootRelativePath()));
+ throw new RuleErrorException();
+ }
return resourceDir;
}
