Skip to content

Support proxy indexes through reversible artifact URLs - #20790

Merged
zsol merged 23 commits into
mainfrom
codex/proxy-indexes-33-complete
Nov 17, 2026
Merged

zsol merged 23 commits into
mainfrom
codex/proxy-indexes-33-complete

Conversation

@zsol

@zsol zsol commented Jul 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Proxy indexes are a preview feature that lets uv resolve and download packages through a proxy while recording the upstream index and artifact URLs in the lockfile. This is useful, for example, when local development uses a proxy that filters out newly published packages but CI uses the upstream index directly. Both can use the same lockfile.

Proxy indexes are configured with [[tool.uv.proxy-index]] in pyproject.toml or [[proxy-index]] in uv.toml. The proxy-for field names an explicitly configured upstream index.

For example, to proxy PyPI in pyproject.toml:

[[tool.uv.index]]
name = "pypi"
url = "https://pypi.org/simple/"
default = true

[[tool.uv.proxy-index]]
name = "pypi-proxy"
url = "https://proxy.example.com/simple/"
artifact-base-url = "https://proxy.example.com/files/"
proxy-for = "pypi"

The path after each artifact base URL must match on both servers. uv swaps the prefixes without checking that the resulting upstream URL exists, so a proxy that changes the rest of the path can produce a lockfile that works only through the proxy.

uv sync --frozen rewrites artifact URLs from uv.lock without querying the proxy's index. Installs from pylock.toml use the proxy only when packages.index identifies the upstream index; otherwise, uv uses the recorded artifact URL.

Implementation overview

  1. Validate proxy configuration. Add a separate proxy table and reject duplicate or ambiguous routes.
  2. Route registry requests through proxies. Use the proxy's request policies, credentials, and cache for index requests. Credentials for a separate artifact host can be configured on artifact-base-url.
  3. Keep upstream artifact URLs in the resolver and lockfiles. Replace the proxy prefix as resolver candidates are constructed, retaining file metadata and hashes.
  4. Apply the reverse mapping for downloads. Verify downloaded bytes and compare recorded hashes before reusing cached artifacts.

Proxy and direct-upstream paths for locking and installation

@zsol
zsol temporarily deployed to automations July 29, 2026 11:43 — with GitHub Actions Inactive
@zsol
zsol force-pushed the codex/proxy-indexes-33-complete branch from 67094f0 to 3092781 Compare July 29, 2026 13:25
Base automatically changed from zsol/proxy-index-02-tool-list-indexes to main July 29, 2026 17:47
@zsol
zsol force-pushed the codex/proxy-indexes-33-complete branch 2 times, most recently from 4ac91da to 34fb4ea Compare July 30, 2026 10:34
@zsol
zsol temporarily deployed to automations July 30, 2026 10:35 — with GitHub Actions Inactive
@astral-sh-bot

astral-sh-bot Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the main base revision.

  • Added tests: 50
  • Removed tests: 0
  • Changed suites: 8
uv-auth: +2 / -0

Added:

  • uv-auth::index::tests::test_authentication_prefers_matching_index_when_roots_overlap
  • uv-auth::index::tests::test_authentication_uses_most_specific_index_root

Removed: none

uv-cli: +1 / -0

Added:

  • uv-cli::settings::tests::proxy_indexes_do_not_persist_physical_credentials_in_tool_receipts

Removed: none

uv-client: +3 / -0

Added:

  • uv-client::registry_client::tests::proxy_artifact_authentication_requires_configured_artifact_credentials
  • uv-client::registry_client::tests::proxy_authentication_prefers_path_specific_policies_and_credentials
  • uv-client::registry_client::tests::simple_detail_proxy_cache_is_physical

Removed: none

uv-distribution: +2 / -0

Added:

  • uv-distribution::hash::tests::artifact_hash_policy_preserves_cache_verification_algorithms
  • uv-distribution::hash::tests::artifact_hash_policy_rejects_wrong_cached_digest

Removed: none

uv-distribution-types: +20 / -0

Added:

  • uv-distribution-types::index::tests::test_index_allows_colons_and_at_signs_in_artifact_paths
  • uv-distribution-types::index::tests::test_index_rejects_unsafe_normalized_artifact_base_paths
  • uv-distribution-types::index::tests::test_proxy_index_serialization_redacts_artifact_credentials
  • uv-distribution-types::index_url::tests::no_index_suppresses_all_proxy_configuration
  • uv-distribution-types::index_url::tests::proxy_indexes_are_excluded_from_resolution_iterators
  • uv-distribution-types::index_url::tests::url_lookup_preserves_proxy_declaration_order
  • uv-distribution-types::proxy_index::tests::proxy_artifact_mapping_preserves_encoded_suffix_and_query
  • uv-distribution-types::proxy_index::tests::proxy_artifact_mapping_requires_a_segment_boundary
  • uv-distribution-types::proxy_index::tests::proxy_custom_index_uses_both_configured_artifact_bases
  • uv-distribution-types::proxy_index::tests::proxy_flat_index_keeps_identity_route
  • uv-distribution-types::proxy_index::tests::proxy_index_ignores_proxies_when_indexes_are_disabled
  • uv-distribution-types::proxy_index::tests::proxy_index_preserves_physical_authentication_credentials
  • uv-distribution-types::proxy_index::tests::proxy_index_rejects_canonical_artifact_credentials
  • uv-distribution-types::proxy_index::tests::proxy_index_rejects_duplicate_index_names
  • uv-distribution-types::proxy_index::tests::proxy_index_rejects_missing_artifact_bases_and_duplicate_targets
  • uv-distribution-types::proxy_index::tests::proxy_index_rejects_unsafe_index_and_artifact_bases
  • uv-distribution-types::proxy_index::tests::proxy_index_requires_a_configured_canonical_index
  • uv-distribution-types::proxy_index::tests::proxy_route_uses_physical_request_policy
  • uv-distribution-types::proxy_index::tests::proxy_simple_route_maps_implicit_pypi
  • uv-distribution-types::proxy_index::tests::request_policy_distinguishes_default_and_explicit_ignored_errors

Removed: none

uv-resolver: +6 / -0

Added:

  • uv-resolver::pubgrub::report::tests::proxy_authentication_hints_respect_no_index
  • uv-resolver::pubgrub::report::tests::proxy_authentication_hints_use_physical_indexes
  • uv-resolver::resolver::provider::tests::ignored_metadata_error_uses_implicit_pypi_proxy_index
  • uv-resolver::resolver::provider::tests::ignored_metadata_error_uses_physical_proxy_index
  • uv-resolver::version_map::tests::canonicalize_proxy_source_preserves_metadata
  • uv-resolver::version_map::tests::canonicalize_proxy_wheel_uses_implicit_pypi_artifact_base

Removed: none

uv-workspace: +2 / -0

Added:

  • uv-workspace::pyproject::tests::canonical_and_proxy_artifact_bases_preserve_index_order
  • uv-workspace::pyproject::tests::invalid_proxy_index_names_and_defaults_are_rejected

Removed: none

uv::it: +14 / -0

Added:

  • uv::it::proxy_index::proxy_index_implicitly_routes_pypi_without_a_second_resolution_index
  • uv::it::proxy_index::proxy_index_installs_existing_locked_artifacts_without_simple_requests
  • uv::it::proxy_index::proxy_index_locks_canonical_urls_without_origin_requests
  • uv::it::proxy_index::proxy_index_pip_compile_pylock_preserves_canonical_artifact_and_hash
  • uv::it::proxy_index::proxy_index_pip_installs_hashless_live_artifact
  • uv::it::proxy_index::proxy_index_redownloads_artifacts_when_proxy_changes
  • uv::it::proxy_index::proxy_index_rejects_and_does_not_cache_locked_artifacts_with_mismatched_hash
  • uv::it::proxy_index::proxy_index_rejects_cached_artifacts_when_advertised_hash_changes
  • uv::it::proxy_index::proxy_index_rejects_duplicate_definitions_across_configuration_files
  • uv::it::proxy_index::proxy_index_rejects_hashless_selected_artifacts
  • uv::it::proxy_index::proxy_index_rejects_same_named_package_index_across_configuration_files
  • uv::it::proxy_index::proxy_index_rejects_unmapped_artifact_without_origin_fallback
  • uv::it::proxy_index::proxy_index_reports_physical_authentication_errors_without_origin_requests
  • uv::it::proxy_index::proxy_index_routes_source_through_proxy_and_reuses_offline_cache

Removed: none

@zsol
zsol force-pushed the codex/proxy-indexes-33-complete branch from 34fb4ea to bd9154e Compare July 30, 2026 11:08
@zsol
zsol temporarily deployed to automations July 30, 2026 11:08 — with GitHub Actions Inactive
@zsol
zsol force-pushed the codex/proxy-indexes-33-complete branch from bd9154e to 4e5bb80 Compare July 30, 2026 16:58
@zsol
zsol temporarily deployed to automations July 30, 2026 16:59 — with GitHub Actions Inactive
@zsol
zsol force-pushed the codex/proxy-indexes-33-complete branch from 4e5bb80 to 51c9cd8 Compare July 31, 2026 16:43
@zsol
zsol temporarily deployed to automations July 31, 2026 16:44 — with GitHub Actions Inactive
@zsol
zsol force-pushed the codex/proxy-indexes-33-complete branch from 51c9cd8 to 4ea9268 Compare August 3, 2026 12:10
@zsol
zsol force-pushed the codex/proxy-indexes-33-complete branch from 4ea9268 to e4cafb3 Compare August 3, 2026 16:54
@zsol
zsol force-pushed the codex/proxy-indexes-33-complete branch from e4cafb3 to 62318dd Compare August 3, 2026 17:10
@zsol
zsol force-pushed the codex/proxy-indexes-33-complete branch from 62318dd to 1041074 Compare August 3, 2026 17:25
@zsol
zsol marked this pull request as ready for review August 3, 2026 17:45
@zsol
zsol requested a review from zanieb August 3, 2026 17:45
@seemethere

seemethere commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

We tested this branch (current revision, 1041074) against a real-world registry pair — Google Artifact Registry + an internal registry — i.e. the enterprise scenario from #6349. One bug and one design gap, both reproducible:

1. Silent lockfile corruption when the proxy doesn't preserve artifact paths

GAR restructures file paths (<name>/<file> rather than PyPI's packages/<hashed-dirs>/<file>). With GAR configured as a PyPI proxy:

[[tool.uv.index]]
name = "gar-proxy"
url = "https://us-python.pkg.dev/<project>/<repo>/simple/"
artifact-base-url = "https://us-python.pkg.dev/<project>/<repo>/"
proxy-for = "pypi"

uv lock succeeds, but the canonical URLs it derives by base-swap don't exist upstream — the lock records e.g.

https://files.pythonhosted.org/packages/idna/idna-3.18.tar.gz   # HTTP 404

Installing through the proxy works (the reverse mapping round-trips), which means tests that only exercise the proxy path won't catch this. Installing the same lock without the proxy — the portability that canonical URLs exist to provide — fails with 404s on the fabricated URLs.

The docs note that path-changing proxies are unsupported, but nothing detects the condition at runtime. Suggestion: hard-error at lock time when a canonical URL can't be derived verifiably, rather than persisting a guess.

2. Path preservation excludes the registries this feature seems aimed at

Of the registries we operate against, no two share a path scheme:

Registry File path after base
PyPI packages/<hashed-dirs>/<file>
Google Artifact Registry <name>/<file>
our internal registry tree/<view>/<name>/<version>/<file>

So GAR (and, we suspect, similarly-shaped registries like AWS CodeArtifact) can't participate as either side of a proxy pair under the current design.

A possible fallback when paths don't align: at install-from-lock time, resolve filename→URL via the proxy's simple index page per locked package — lockfile hashes already guarantee integrity regardless of which URL served the bytes. On cost: we measured this exact access pattern against GAR (worst-case index chatter — it serves neither PEP 658 nor PEP 691): ~5s of index fetches for a 235-package lock at modest parallelism, dwarfed by 4.7GB of wheel downloads.

Happy to test iterations of this branch — we have a production-scale bed for it: two live registries with byte-identical mirrored artifacts and a 799-entry dual-arch lockfile.

AI caveat: an agent wrote this but I reviewed it

@zsol

zsol commented Aug 21, 2026

Copy link
Copy Markdown
Member Author

@seemethere thanks for the feedback! We'll solve 2 in a followup PR. As for 1, that's an intentional design choice here.

Comment thread crates/uv-settings/src/settings.rs Resolved

This branch was previously deployed

1 inactive deployment
automations — b5bb3b31 Deployed Nov 17, 2026 by zsol via check | crates / cargo-vet in crates/uv-trampoline #54053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants