Skip to content

Commit aa67e4c

Browse files
fmeumcopybara-github
authored andcommitted
Do not print repository errors twice
Instead of ``` ERROR: An error occurred during the fetch of repository 'mydep~': Traceback (most recent call last): File "/private/var/tmp/_bazel_fmeum/7d8a4807d1079f03870ba5776e9ca66b/external/bazel_tools/tools/build_defs/repo/http.bzl", line 142, column 45, in _http_archive_impl download_info = ctx.download_and_extract( Error in download_and_extract: java.io.IOException: Bad URL: invalid ERROR: <builtin>: fetching http_archive rule //:mydep~: Traceback (most recent call last): File "/private/var/tmp/_bazel_fmeum/7d8a4807d1079f03870ba5776e9ca66b/external/bazel_tools/tools/build_defs/repo/http.bzl", line 142, column 45, in _http_archive_impl download_info = ctx.download_and_extract( Error in download_and_extract: java.io.IOException: Bad URL: invalid ERROR: Error computing the main repository mapping: error during computation of main repo mapping: java.io.IOException: Bad URL: invalid ``` print ``` ERROR: An error occurred during the fetch of repository 'mydep~': Traceback (most recent call last): File "/private/var/tmp/_bazel_fmeum/7d8a4807d1079f03870ba5776e9ca66b/external/bazel_tools/tools/build_defs/repo/http.bzl", line 142, column 45, in _http_archive_impl download_info = ctx.download_and_extract( Error in download_and_extract: java.io.IOException: Bad URL: invalid ERROR: Error computing the main repository mapping: error during computation of main repo mapping: java.io.IOException: Bad URL: invalid ``` Fixes #22520 Closes #22522. PiperOrigin-RevId: 637954405 Change-Id: Iec55a5cf7cb287f692bd26fc1937379aa8b1853f
1 parent b4d3b84 commit aa67e4c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryFunction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ private RepositoryDirectoryValue.Builder fetchInternal(
401401
env.getListener()
402402
.handle(Event.info(RepositoryResolvedEvent.getRuleDefinitionInformation(rule)));
403403

404-
throw new RepositoryFunctionException(e, Transience.TRANSIENT);
404+
throw new RepositoryFunctionException(
405+
new AlreadyReportedRepositoryAccessException(e), Transience.TRANSIENT);
405406
}
406407

407408
if (!outputDirectory.isDirectory()) {

src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.google.devtools.build.lib.rules.repository.RepositoryDirectoryValue.NoRepositoryDirectoryValue;
4242
import com.google.devtools.build.lib.rules.repository.RepositoryFunction.AlreadyReportedRepositoryAccessException;
4343
import com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException;
44+
import com.google.devtools.build.lib.skyframe.AlreadyReportedException;
4445
import com.google.devtools.build.lib.skyframe.PrecomputedValue;
4546
import com.google.devtools.build.lib.skyframe.PrecomputedValue.Precomputed;
4647
import com.google.devtools.build.lib.util.Fingerprint;
@@ -424,6 +425,10 @@ private RepositoryDirectoryValue.Builder fetchRepository(
424425
// Upon an exceptional exit, the fetching of that repository is over as well.
425426
env.getListener().post(RepositoryFetchProgress.finished(repoName));
426427
env.getListener().post(new RepositoryFailedEvent(repoName, e.getMessage()));
428+
429+
if (e.getCause() instanceof AlreadyReportedException) {
430+
throw e;
431+
}
427432
env.getListener()
428433
.handle(
429434
Event.error(

0 commit comments

Comments
 (0)