Skip to content

Conversation

@seemethere
Copy link
Contributor

@seemethere seemethere commented Dec 1, 2025

Summary

This allows users to set the HTTP, HTTPS, and no proxy variables via the configuration files like pyproject.toml and uv.toml.

Users can set like so:

uv.toml

https-proxy = "http://my_cool_proxy:10500"
http-proxy = "http://my_cool_proxy:10500"
no-proxy = [
  "dontproxyme.com",
  "localhost",
]

Resolves #9472

Test Plan

It also adds a new integration test for the proxy support in uv-client.

This was tested on some of our developer machines with our proxy setup using ~/.config/uv/uv.toml with values like:

https-proxy = "http://my_cool_proxy:10500"
http-proxy = "http://my_cool_proxy:10500"
no-proxy = [
  "dontproxyme.com",
  "localhost",
]

@samypr100
Copy link
Collaborator

samypr100 commented Dec 2, 2025

@seemethere Thanks for the contribution, please see CONTRIBUTING.md to help guide which issues are open to contributions. (edit: initial discussions already happened in a separate medium)

For reference on this one, see #9461 (comment) which I believe will need to be addressed first before we can commit to a design for this issue.

@zanieb
Copy link
Member

zanieb commented Dec 2, 2025

I think uv.toml support without pyproject.toml support feels reasonable? Without looking at the pull request in detail yet, I had a similar concern to @samypr100. We're generally avoiding system-level options in the pyproject.toml.

@zanieb
Copy link
Member

zanieb commented Dec 2, 2025

Would that work for your use-case?

@seemethere
Copy link
Contributor Author

Would that work for your use-case?

Yup this still works for my use case!

@seemethere
Copy link
Contributor Author

I think uv.toml support without pyproject.toml support feels reasonable? Without looking at the pull request in detail yet, I had a similar concern to @samypr100. We're generally avoiding system-level options in the pyproject.toml.

I'll fix this up to do that! Will ping when it's ready!

@seemethere
Copy link
Contributor Author

seemethere commented Dec 2, 2025

Okay should be updated now errors should look like:

Screenshot 2025-12-02 at 10 55 06 AM
~/work/uv/scratch seemethere/add_proxy_configuration*
❯ ../target/debug/uv sync
error: Failed to parse: `pyproject.toml`. The `http-proxy` field is not allowed in a `pyproject.toml` file. `http-proxy` is a system-level setting and should be placed in a `uv.toml` file instead.

Also added a test case to validate this in show_settings.rs

@seemethere seemethere force-pushed the seemethere/add_proxy_configuration branch from 333c2f1 to 0daef69 Compare December 5, 2025 00:47
@seemethere
Copy link
Contributor Author

Rebased this to fix the merge conflicts!

@seemethere seemethere changed the title Allow setting proxy variables via configuration Allow setting proxy variables via global / user configuration Dec 5, 2025
}

if let Some(http_proxy) = &self.http_proxy {
let mut proxy = Proxy::http(http_proxy).expect("Invalid HTTP proxy URL");
Copy link
Member

Choose a reason for hiding this comment

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

We can't panic on user-facing input here. We should validate these values much earlier and raise errors instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay! Added a ProxyUrl type to handle this, this should surface errors a lot better.

Errors (from user POV) should look like:

invalid proxy URL scheme `ftp` in `ftp://proxy.example.com`: expected http, https, socks5, or socks5h
invalid proxy URL: relative URL without a base

Comment on lines 1329 to 1334
=== "pyproject.toml"

```toml
[tool.uv]
http-proxy = "http://proxy.example.com"
```
Copy link
Member

Choose a reason for hiding this comment

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

It seems problematic to show these pyproject.toml examples in the settings reference if we're not going to allow it, we might need to invest in infrastructure to omit that before this can land.

Copy link
Member

Choose a reason for hiding this comment

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

See #16918 (comment) though

Comment on lines +306 to +308
http_proxy,
https_proxy,
no_proxy,
Copy link
Member

Choose a reason for hiding this comment

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

I started looking at this and I feel like we might need a validate_pyproject_toml function like validate_uv_toml? We won't hard deny any of these options in the pyproject.toml toda.

I'm surprised that we allow allow_insecure_host in the pyproject.toml today, which might mean my and @samypr100's points aren't really in scope for this work.

Copy link
Member

@zanieb zanieb Dec 9, 2025

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think my understanding of what we weren't allowing today is wrong and it probably doesn't make sense to block this on fixing that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm surprised that we allow allow_insecure_host in the pyproject.toml today

Gasp 😓

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's fine, I added a utility that should be able to allow us to do this, I can also submit a follow-up PR to not include the other ones (like insecure_host) as well if we want.

@seemethere seemethere force-pushed the seemethere/add_proxy_configuration branch 3 times, most recently from d2bc450 to aa29a79 Compare December 10, 2025 04:59
Comment on lines 553 to 557
let mut proxy = Proxy::http(http_proxy.as_str())
.expect("pre-validated HTTP proxy URL should be valid");
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why we're not using the Proxy type directly for validation? Why do we add a wrapper type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The wrapper type includes a Deserialize implementation which reqwest::Proxy does not, as well the error messaging is a bit more informative than the generic error building client: builder error you might get from reqwest.

Happy to rework this though if we feel like it's overkill.

Copy link
Member

Choose a reason for hiding this comment

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

Why does it wrap Url instead of Proxy?

I'm just trying to understand the pattern here as something feels a bit off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it mostly comes down to Proxy being a suitable type for the runtime http client while being an unsuitable type for expressing user configuration.

I think in general what we're expressing with http_proxy and https_proxy are URLs that have routing rules expressed through their variable names.

We also get the benefits of inheriting some of the things from Url like PartialEq, Serialize, etc. which Proxy doesn't have.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do think that perhaps this would be something that should be upstreamed to reqwest since it might also be generally useful for other people too.

@zanieb zanieb self-assigned this Dec 11, 2025
@zanieb
Copy link
Member

zanieb commented Dec 11, 2025

I'm out sick today but my next step is to futz with this locally and propose some tweaks based on that.

@seemethere
Copy link
Contributor Author

I'm out sick today but my next step is to futz with this locally and propose some tweaks based on that.

Sounds good! I hope you feel better!

This allows users to set the HTTP, HTTPS, and no proxy variables via the configuration files like
uv.toml.

This adds ProxyUrl type to surface errors earlier to users for invalid
ProxyUrls.

Also adds a uv_toml_only variable that allows us to specify specific
options that are only intended for the uv.toml file and disinclude them
from the generated docs for pyproject.toml examples.

It also adds a new integration test for the proxy support in `uv-client`.

Signed-off-by: Eli Uriegas <eliuriegas@meta.com>
@seemethere seemethere force-pushed the seemethere/add_proxy_configuration branch from aa29a79 to 46b0c96 Compare December 16, 2025 17:24
@zanieb
Copy link
Member

zanieb commented Jan 6, 2026

Alright sorry for the delay from the holiday time off :)

I've pushed a commit that does a few things

  1. Moves conversion into the reqwest::Proxy type into our wrapper ProxyUrl type to consolidate the safety logic
  2. Adds curl / reqwest compatible http:// scheme assumption
  3. Adds CLI-level integration tests

and I've resolved the conflict with main.

Please give it a look over and let me know if you have any questions or concerns.

@seemethere
Copy link
Contributor Author

Alright sorry for the delay from the holiday time off :)

I've pushed a commit that does a few things

  1. Moves conversion into the reqwest::Proxy type into our wrapper ProxyUrl type to consolidate the safety logic
  2. Adds curl / reqwest compatible http:// scheme assumption
  3. Adds CLI-level integration tests

and I've resolved the conflict with main.

Please give it a look over and let me know if you have any questions or concerns.

LGTM!

@zanieb zanieb merged commit e67dbce into astral-sh:main Jan 6, 2026
262 of 271 checks passed
@zanieb zanieb added the configuration Settings and such label Jan 6, 2026
@charliermarsh
Copy link
Member

This is live in v0.9.23.

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 12, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.9.22` → `0.9.24` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.9.24`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0924)

[Compare Source](astral-sh/uv@0.9.23...0.9.24)

Released on 2026-01-09.

##### Bug fixes

- Fix handling of `UV_NO_SYNC=1 uv run ...` ([#&#8203;17391](astral-sh/uv#17391))
- Rebuild dynamic distribution when version changes with `--no-cache` ([#&#8203;17387](astral-sh/uv#17387))

##### Documentation

- Add Rust language classifier ([#&#8203;17389](astral-sh/uv#17389))

### [`v0.9.23`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0923)

[Compare Source](astral-sh/uv@0.9.22...0.9.23)

Released on 2026-01-09.

##### Enhancements

- Only write portable paths in `RECORD` files ([#&#8203;17339](astral-sh/uv#17339))
- Support relative paths in `UV_PYTHON_BIN_DIR` and `UV_TOOL_BIN_DIR` ([#&#8203;17367](astral-sh/uv#17367))

##### Preview features

- Enable uploads to S3 via pre-signed URLs ([#&#8203;17349](astral-sh/uv#17349))

##### Configuration

- Allow setting proxy variables via global / user configuration ([#&#8203;16918](astral-sh/uv#16918))
- Manually parse and reconcile Boolean environment variables ([#&#8203;17321](astral-sh/uv#17321))

##### Bug fixes

- Avoid broken build artifacts on build failure ([#&#8203;17276](astral-sh/uv#17276))
- Fix missing dependencies on synthetic root in SBOM export ([#&#8203;17363](astral-sh/uv#17363))
- Recognize `armv8l` as an alias for `armv7l` in platform tag parsing ([#&#8203;17384](astral-sh/uv#17384))
- Fix redaction of a URL in a middleware trace log ([#&#8203;17346](astral-sh/uv#17346))

##### Documentation

- Add `index.md` suggestion to `llms.txt` ([#&#8203;17362](astral-sh/uv#17362))
- Clarify that `uv run` uses inexact syncing by default ([#&#8203;17366](astral-sh/uv#17366))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43NS4xIiwidXBkYXRlZEluVmVyIjoiNDIuNzUuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
zaniebot pushed a commit to zaniebot/uv that referenced this pull request Jan 14, 2026
Following astral-sh#16918, mark additional system-level settings as `uv_toml_only`
so they don't appear in the `pyproject.toml` documentation examples:

- `native-tls`: System-level TLS configuration that depends on the OS
  certificate store
- `cache-dir`: Machine-specific filesystem paths
- `python-install-mirror`: Organization-specific mirror URLs
- `pypy-install-mirror`: Organization-specific mirror URLs
- `python-downloads-json-url`: Organization-specific URLs

These settings are machine/user/organization-specific and shouldn't be
committed to VCS via `pyproject.toml`.
zanieb added a commit that referenced this pull request Jan 14, 2026
…ngs (#17462)

Following #16918, mark additional system-level settings as
`uv_toml_only` so they don't appear in the `pyproject.toml`
documentation examples:

- `native-tls`
- `cache-dir`
- `python-install-mirror`
- `pypy-install-mirror`
- `python-downloads-json-url`

Eventually, we'll want to ban these in the `pyproject.toml` without some
opt-in.

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Settings and such

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuration of HTTPS proxy in the pyproject.toml

4 participants