Skip to content

Conversation

@bazel-io
Copy link
Member

When a mirror URL fails with an SSLException (e.g. expired certificate), the downloader should fail over to the next mirror immediately instead of retrying the failing URL multiple times.

Fixes #28158

RELNOTES: Bazel now fails over immediately to mirror URLs if a TLS handshake error occurs.

CC @lberki @fmeum @Wyv

Closes #28347.

PiperOrigin-RevId: 861936486
Change-Id: If40b966224c1e0687dd258adb2c03bbf055b8c40

Commit 5594c2a

…ld#28347)

When a mirror URL fails with an SSLException (e.g. expired certificate), the downloader should fail over to the next mirror immediately instead of retrying the failing URL multiple times.

Fixes bazelbuild#28158

RELNOTES: Bazel now fails over immediately to mirror URLs if a TLS handshake error occurs.

CC @lberki @fmeum @Wyv

Closes bazelbuild#28347.

PiperOrigin-RevId: 861936486
Change-Id: If40b966224c1e0687dd258adb2c03bbf055b8c40
@bazel-io bazel-io added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Jan 28, 2026
@bazel-io bazel-io requested a review from a team as a code owner January 28, 2026 00:39
@bazel-io bazel-io added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Jan 28, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a crucial improvement by ensuring that the repository downloader fails over immediately when encountering TLS handshake errors, such as expired certificates. This change enhances the reliability of downloads by preventing unnecessary retries on unrecoverable errors. A new test case has been added to validate this behavior, and the code has been refactored to use FileSystemUtils.readContent for file operations.

Comment on lines +172 to +174
if (e.getMessage() != null
&& (e.getMessage().contains("certificate")
|| e.getMessage().contains("CertPathValidatorException"))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Relying on string matching (e.getMessage().contains("certificate") || e.getMessage().contains("CertPathValidatorException")) to identify permanent TLS errors is fragile. Exception messages can vary across Java versions or different SSL/TLS providers, potentially leading to incorrect error classification and retry behavior. A more robust approach would be to inspect the cause chain of the SSLException for specific exception types related to certificate validation (e.g., java.security.cert.CertificateException or javax.net.ssl.SSLHandshakeException with a CertificateException in its cause).

@iancha1992
Copy link
Member

Might be replaced by #28461?

Ashutosh0x added a commit to Ashutosh0x/bazel that referenced this pull request Jan 29, 2026
This commit adds the missing test case from PR bazelbuild#28459 as requested by
@iancha1992. The changes include:
- Updated imports to use FileSystemUtils instead of DataInputStream
- Replaced the readFile() method with FileSystemUtils.readContent()
- Added downloadFrom2UrlsFirstTlsErrorSecondOk() test to verify TLS
  error failover behavior

These changes ensure that the test coverage for TLS error handling is
complete and consistent with the main PR bazelbuild#28459.
@meteorcloudy
Copy link
Member

I would merge this one since it's prepared by a deterministic bot instead of a undeterministric one.

@iancha1992 iancha1992 added this pull request to the merge queue Jan 30, 2026
@Ashutosh0x
Copy link
Contributor

Thanks, @meteorcloudy appreciate it!

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2026
@meteorcloudy meteorcloudy added this pull request to the merge queue Jan 30, 2026
Merged via the queue into bazelbuild:release-8.6.0 with commit 2ea95c4 Jan 30, 2026
47 checks passed
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants