The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): preserve transport knobs under no_config isolation, strip only index redirects
Yuan Li80e834b1299c
diff --git a/pm/environment.py b/pm/environment.pyindex a2f7d03c3c8..076ebd8c9b7 100644--- a/pm/environment.py+++ b/pm/environment.py@@ -278,10 +278,12 @@ class PythonEnvironment:# builder asked to be isolated from ambient index configuration:# re-resolving its official-index lockfile against a mirror trips# `--locked` (#124418), and a fully-pinned graph never needs a- # mirror to resolve.- from pm.index_config import is_forwarded+ # mirror to resolve. Index-REDIRECT settings are dropped; transport+ # knobs (UV_NATIVE_TLS / UV_INSECURE_HOST / UV_HTTP_TIMEOUT) survive+ # — corporate networks need them to reach the pinned URLs at all.+ from pm.index_config import is_index_redirect- env = {key: value for key, value in env.items() if not is_forwarded(key)}+ env = {key: value for key, value in env.items() if not is_index_redirect(key)}env.update(UV_PYTHON=str(self.python), UV_PROJECT_ENVIRONMENT=str(self.destination),UV_CACHE_DIR=str(self.cache), UV_PYTHON_DOWNLOADS="never")with tempfile.TemporaryDirectory(prefix="pm-uv-config-") as config:diff --git a/pm/index_config.py b/pm/index_config.pyindex 83b6ce96b76..d58d677ddd4 100644--- a/pm/index_config.py+++ b/pm/index_config.py@@ -44,6 +44,23 @@ def is_forwarded(key: str) -> bool:return key in FORWARDED_UV_SETTINGS or key.startswith("UV_INDEX_")+# Settings that redirect WHERE packages resolve from (index URLs, find-links,+# resolution strategy, index credentials). These are what no_config isolation+# must strip from the child: re-resolving the official-index runtime lockfile+# against a mirror is exactly what trips `uv sync --locked` (#124418/#125071).+# Transport knobs (UV_NATIVE_TLS, UV_INSECURE_HOST, UV_HTTP_TIMEOUT) are NOT+# index redirects — corporate networks need them to reach the pinned URLs at+# all, so they survive no_config isolation.+INDEX_REDIRECT_SETTINGS = frozenset({+ "UV_INDEX_URL", "UV_EXTRA_INDEX_URL", "UV_DEFAULT_INDEX", "UV_INDEX", "UV_NO_INDEX",+ "UV_FIND_LINKS", "UV_INDEX_STRATEGY", "UV_KEYRING_PROVIDER",+})+++def is_index_redirect(key: str) -> bool:+ return key in INDEX_REDIRECT_SETTINGS or key.startswith("UV_INDEX_")++def pip_config_candidates(env: Mapping[str, str]) -> list[Path]:"""pip's config files, lowest precedence first, as ``pip._internal.configuration`` ranks them.diff --git a/tests/pm/test_environment_build.py b/tests/pm/test_environment_build.pyindex f0b027d3cf6..26a70c568da 100644--- a/tests/pm/test_environment_build.py+++ b/tests/pm/test_environment_build.py@@ -790,20 +790,24 @@ def test_live_apply_keeps_selection_on_failed_union(locked_project, tmp_path, modef test_no_config_drops_bridged_index_settings_from_child_env(tmp_path):- """no_config must isolate the pinned runtime builder from ALL ambient uv- configuration: --no-config covers config files, but PM's pip-mirror bridge+ """no_config must isolate the pinned runtime builder from ambient INDEX+ redirection: --no-config covers config files, but PM's pip-mirror bridgeinjects UV_INDEX_URL as an env var, and re-resolving the official-indexruntime lockfile against that mirror trips `uv sync --locked` (#124418).- The default path keeps the bridge — mirrored networks need it to resolve- their application dependencies at all."""+ Transport knobs are NOT index redirects and must survive isolation —+ corporate networks need UV_HTTP_TIMEOUT et al. to reach the pinned URLs.+ The default path keeps the whole bridge — mirrored networks need it to+ resolve their application dependencies at all."""import iofrom pm.environment import PythonEnvironmentambient = dict(os.environ, UV_INDEX_URL="https://fixture-mirror.invalid/simple",UV_HTTP_TIMEOUT="99")child = ("import os, sys\n"- "present = sorted(k for k in ('UV_INDEX_URL', 'UV_HTTP_TIMEOUT') if k in os.environ)\n"- "sys.exit(', '.join(present) if present else None)\n")+ "if 'UV_INDEX_URL' in os.environ:\n"+ " sys.exit('leaked index redirect: UV_INDEX_URL')\n"+ "if 'UV_HTTP_TIMEOUT' not in os.environ:\n"+ " sys.exit('transport knob dropped: UV_HTTP_TIMEOUT')\n")def run(**kwargs):environment = PythonEnvironment(@@ -812,7 +816,7 @@ def test_no_config_drops_bridged_index_settings_from_child_env(tmp_path):return environment._run(["-c", child], cwd=tmp_path, timeout=60)isolated = run(no_config=True)- assert isolated.returncode == 0, f"bridged settings leaked into no_config child: {isolated.stderr}"+ assert isolated.returncode == 0, f"isolation wrong: {isolated.stderr}"bridged = run()assert bridged.returncode == 1, "default path must keep the bridge"- assert "UV_INDEX_URL" in bridged.stderr and "UV_HTTP_TIMEOUT" in bridged.stderr+ assert "UV_INDEX_URL" in bridged.stderr, bridged.stderr