diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java b/src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java index 285c45fa1cbec7..9dc0b1c3f04729 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java @@ -146,9 +146,8 @@ public Iterable getPackagesUnderDirectory( } if (!repositoryValue.repositoryExists()) { - // This shouldn't be possible; we're given a repository, so we assume that the caller has - // already checked for its existence. - throw new IllegalStateException(String.format("No such repository '%s'", repository)); + eventHandler.handle(Event.error(String.format("No such repository '%s'", repository))); + return ImmutableList.of(); } roots.add(repositoryValue.getPath()); } diff --git a/src/test/shell/bazel/external_correctness_test.sh b/src/test/shell/bazel/external_correctness_test.sh index 5dd6ca15c95671..d497aa9e05367e 100755 --- a/src/test/shell/bazel/external_correctness_test.sh +++ b/src/test/shell/bazel/external_correctness_test.sh @@ -331,4 +331,9 @@ function test_top_level_dir_changes_nobatch() { top_level_dir_changes_helper --nobatch } +function test_non_extsietnt_repo_in_pattern() { + bazel build @non_existent_repo//... &> $TEST_log && fail "Expected build to fail" + expect_log "ERROR: No such repository '@non_existent_repo'" +} + run_suite "//external correctness tests"