Skip to content

Conversation

@srikantharun
Copy link

@srikantharun srikantharun commented Jan 10, 2026

Summary

Fixes #28158

  • SSL/TLS errors (expired certificates, hostname mismatches) are now treated as non-retriable
  • Throws UnrecoverableHttpException for SSLException, allowing HttpConnectorMultiplexer to immediately try alternative URLs
  • Consistent with existing handling of UnknownHostException

Problem

When a TLS certificate expires on a mirror server, Bazel retries the same URL up to 8 times before failing. This wastes time when alternative mirror URLs are available that could succeed.

Solution

Catch SSLException and throw UnrecoverableHttpException instead of retrying. This signals the multiplexer to fallback to the next available URL immediately.

Changes

  • HttpConnector.java: Added catch block for SSLException that throws UnrecoverableHttpException
  • HttpConnectorTest.java: Added sslError_throwsUnrecoverableHttpException() test

Test plan

  • Added unit test sslError_throwsUnrecoverableHttpException() that verifies SSL errors throw UnrecoverableHttpException
  • Existing tests pass
  • Manual verification with expired certificate scenario

Fixes bazelbuild#28158

SSL/TLS errors such as expired certificates or hostname mismatches
are not transient - retrying the same URL will not resolve them.
Previously, these errors were retried up to 8 times before failing,
wasting time when alternative mirror URLs were available.

This change catches SSLException and throws UnrecoverableHttpException,
which signals HttpConnectorMultiplexer to immediately try the next
available URL instead of retrying the failing one.

This is consistent with how UnknownHostException is already handled.
@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Jan 10, 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 correctly addresses the issue of retrying on SSL/TLS errors by treating them as unrecoverable, which will allow fallback to other URLs. The implementation is straightforward. My main concern is the lack of automated tests for this new behavior. While manual verification is planned, adding an automated test case would be crucial to prevent future regressions for this important networking logic. Additionally, the new code for handling SSLException duplicates logic from the existing UnknownHostException handler. I've left a comment with a suggestion to improve consistency and noted this as a candidate for future refactoring to improve maintainability.

- Use format() helper method for error message construction
  for consistency with other logging in the file
- Add unit test sslError_throwsUnrecoverableHttpException()
  that verifies SSL errors are treated as non-retriable
The test scenario (HTTPS connection to plain HTTP server) triggers
different exception types on Windows vs Linux/macOS. Skip the test
on Windows since the actual SSL certificate handling is tested on
other platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

download_and_extract: fail over to other URLs if a TLS certificate is expired

1 participant