Skip to content

Conversation

@assadyousuf
Copy link
Contributor

@assadyousuf assadyousuf commented Oct 11, 2025

Summary

SSL errors should not be retryable from the cached on non cached client: #16235

Test Plan

Unsure on if its possible/how to simulate an SSL certificate failure with the mock server so we can get a test going. Open to ideas on how to test this. See comment below

@assadyousuf assadyousuf marked this pull request as ready for review October 15, 2025 00:15
@assadyousuf assadyousuf changed the title Fix: Dont retry connection on SSL errors Dont retry connection on SSL errors Oct 15, 2025
}
}

// Use the default strategy and check for additional transient error cases.
Copy link
Contributor Author

@assadyousuf assadyousuf Oct 15, 2025

Choose a reason for hiding this comment

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

Unsure on if its possible/how to simulate an SSL certificate failure with the mock server so we can get a test going. Open to ideas on how to test the new code path

Copy link
Member

Choose a reason for hiding this comment

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

I don't have a great idea either unfortunately, I'm using https://badssl.com/ for manual testing but we don't want to make CI depend on a third-party website. I tried building something with https://github.com/rustls/rcgen but it was clashing with the rustls features we were enabling, it would be great if we could fix that on the rcgen side and then use a self-signed cert in the test.

Copy link
Collaborator

@samypr100 samypr100 Oct 23, 2025

Choose a reason for hiding this comment

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

I would think setting SSL_CERT_FILE to a self signed cert chain in the test context may help, e.g. maybe with a self-signed cert for pypi.org and running typical uv project commands. I'd expect it to fail on hostname validation.

If we really need some other kind of testing requiring our own mocked server, we could use a similar approach like we did here, but would require some additional minor setup to get some dummy certs working.

@assadyousuf assadyousuf changed the title Dont retry connection on SSL errors Dont retry connection on SSL certificate error Oct 15, 2025
}
}

// Use the default strategy and check for additional transient error cases.
Copy link
Member

Choose a reason for hiding this comment

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

I don't have a great idea either unfortunately, I'm using https://badssl.com/ for manual testing but we don't want to make CI depend on a third-party website. I tried building something with https://github.com/rustls/rcgen but it was clashing with the rustls features we were enabling, it would be great if we could fix that on the rcgen side and then use a self-signed cert in the test.


impl RetryableStrategy for UvRetryableStrategy {
fn handle(&self, res: &Result<Response, reqwest_middleware::Error>) -> Option<Retryable> {
if let Err(err) = res {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have this check both here and in is_transient_network_error?

if let reqwest_middleware::Error::Reqwest(reqwest_err) = &**reqwest_err {
if default_on_request_error(reqwest_err) == Some(Retryable::Transient) {
if is_ssl_request_error(reqwest_err) {
trace!("Cannot retry nested reqwest middleware SSL error");
Copy link
Member

Choose a reason for hiding this comment

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

We should return false here.

@konstin konstin self-assigned this Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants