Skip to content

Move parsing http retries to EnvironmentOptions#16284

Merged
konstin merged 12 commits intoastral-sh:mainfrom
andrey-berenda:move-http-retries-to-EnvironmentOptions
Oct 21, 2025
Merged

Move parsing http retries to EnvironmentOptions#16284
konstin merged 12 commits intoastral-sh:mainfrom
andrey-berenda:move-http-retries-to-EnvironmentOptions

Conversation

@andrey-berenda
Copy link
Copy Markdown
Contributor

Summary

  • Move parsing UV_HTTP_RETRIES to EnvironmentOptions

Relates #14720

Test Plan

  • Tests with existing tests


/// Create a [`RetryPolicy`] for the client.
fn retry_policy(&self) -> ExponentialBackoff {
pub fn retry_policy(&self) -> ExponentialBackoff {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made this function public and use this
Just not to use DEFAULT_RETRIES

Comment thread crates/uv-settings/src/lib.rs Outdated
.or(http_timeout)
.unwrap_or(Duration::from_secs(15 * 60)),
http_timeout: http_timeout.unwrap_or(Duration::from_secs(30)),
http_retries: parse_u32_environment_variable(EnvVars::UV_HTTP_RETRIES)?.unwrap_or(3),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I used 3 here
It should be the same as DEFAULT_RETRIES
I used 3 instead of DEFAULT_RETRIES because I do not want to add uv-client as deps here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is already a transitive dependency from uv-settings to uv-client, so adding the dependency is effectively for free.

image

@andrey-berenda andrey-berenda marked this pull request as ready for review October 13, 2025 17:03
@andrey-berenda andrey-berenda force-pushed the move-http-retries-to-EnvironmentOptions branch from 5f21ead to 9be8dfa Compare October 16, 2025 09:08
@konstin konstin added the internal A refactor or improvement that is not user-facing label Oct 20, 2025
Comment thread crates/uv-settings/src/lib.rs Outdated

/// Parse a integer environment variable.
fn parse_u32_environment_variable(name: &'static str) -> Result<Option<u32>, Error> {
parse_integer_environment_variable(name, "expected an non-negative integer")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we show the actual error message from parsing instead of our generic one? This solves the error message regression.

After doing that, we shouldn't need those wrapper functions anymore, but can use e.g. parse_integer_environment_variable::<u32> directly.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fixed

Comment thread crates/uv/tests/it/network.rs Outdated
Comment on lines +341 to +354
error: Failed to parse `UV_HTTP_RETRIES`
Caused by: number too large to fit in target type
error: Failed to parse environment variable `UV_HTTP_RETRIES` with invalid value `999999999999`: expected an non-negative integer
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the regression in the error message I mentioned in the other comment.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fixed

Copy link
Copy Markdown
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

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

Thank you!

@konstin konstin enabled auto-merge (squash) October 20, 2025 12:17
auto-merge was automatically disabled October 20, 2025 12:20

Head branch was pushed to by a user without write access

@konstin konstin enabled auto-merge (squash) October 20, 2025 12:20
@aberenda-optifino
Copy link
Copy Markdown

Could you please retry this?
https://github.com/astral-sh/uv/actions/runs/18651784234/job/53171692215?pr=16284
It seems only this is required to merge
@konstin

@konstin
Copy link
Copy Markdown
Member

konstin commented Oct 20, 2025

Our depot runner are affected by the AWS outage (https://status.depot.dev/), sorry for the disruption.

auto-merge was automatically disabled October 20, 2025 15:39

Head branch was pushed to by a user without write access

@konstin konstin enabled auto-merge (squash) October 20, 2025 15:55
auto-merge was automatically disabled October 21, 2025 00:27

Head branch was pushed to by a user without write access

@konstin konstin merged commit 51e8da2 into astral-sh:main Oct 21, 2025
150 of 161 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants