Skip to content

Search a workspace member's own indexes during resolution - #20922

Open
TemRevil wants to merge 2 commits into
astral-sh:mainfrom
TemRevil:fix/workspace-member-index-not-consulted
Open

TemRevil wants to merge 2 commits into
astral-sh:mainfrom
TemRevil:fix/workspace-member-index-not-consulted

Conversation

@TemRevil

@TemRevil TemRevil commented Aug 3, 2026

Copy link
Copy Markdown

Summary

Closes #20678.

uv add --index inside a workspace member writes the index into that member's own pyproject.toml. But the resolver's actual index locations only ever come from the workspace root's [[tool.uv.index]] entries plus the CLI (Workspace::indexes() is documented as "the index table from the workspace pyproject.toml", root only). The member's index stays readable for two narrower things, a named tool.uv.sources lookup and credential extraction, but it never gets added to the set of indexes actually searched for candidates. Outside the one case the issue calls out (a single named index gets pinned via tool.uv.sources, so it happens to work through that narrower path), the member's index is a silent no-op.

Fix extends the resolved IndexLocations in do_lock with every workspace member's own indexes, reusing LockTarget::indexes(), which already walks root plus all members correctly for the credentials-only case. Covers both uv lock and uv sync, since sync goes through the same do_lock via LockOperation.

Test Plan

Read through Workspace::indexes() and its three call sites first to find the actual root cause, then confirmed it empirically before writing any fix: in a python:3.12-slim container, installed the published uv 0.12.1, set an unreachable index as the workspace root's default and a real one only in a member's pyproject.toml, ran uv lock, and watched it request only the bogus root index and never touch the member's.

Added lock_index_workspace_member_without_source_pin next to the existing lock_index_workspace_member test, same pypi_proxy setup but without the tool.uv.sources pin, so it exercises the "just search this index" path instead of the named-lookup path. Confirmed it fails without the fix (same symptom as the manual repro above) and passes with it, by stashing just the source change and rerunning.

cargo check, cargo fmt, and cargo clippy --tests -D warnings all clean.

uv add --index inside a workspace member writes the index into that
member's pyproject.toml, but the resolver only ever searched indexes
defined at the workspace root plus the CLI. The member's index stayed
readable for named tool.uv.sources pins and credential extraction, but
was never actually searched for candidates, making it an effective
no-op for anything else.

Extend the resolved index locations with every member's own indexes
before they reach the registry client and build dispatch, so lock and
sync both pick them up.

Fixes astral-sh#20678
…vior

Locking without credentials now correctly reaches the member's own
index (that's this PR's fix) and reports the real 401, instead of
silently treating the package as absent from the registry.
@TemRevil

TemRevil commented Aug 4, 2026

Copy link
Copy Markdown
Author

Fixed the CI failure. The pre-existing lock_index_workspace_member test wasn't touched by this PR, but it exercises the same scenario the fix touches (a workspace member's own index, referenced through a tool.uv.sources pin). With the fix applied, that index is now actually reached during resolution, so the no-credentials case correctly reports a 401 against it instead of silently falling through to "not found in the package registry." The stored snapshot just hadn't caught up to the new (better) message. Updated it to match.

Couldn't get a full local test run working in this environment (Git's own link.exe shadows the MSVC linker on PATH, and Docker wasn't available), so I verified this specific change against the actual CI failure output rather than a fresh local pass. Flagging in case anything else needs a second look on the next run.

@astral-sh-bot

astral-sh-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

uv test inventory changes

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

  • Added tests: 1
  • Removed tests: 0
  • Changed suites: 1
uv::lock: +1 / -0

Added:

  • uv::lock::lock::lock_index_workspace_member_without_source_pin

Removed: none

This branch has not been deployed

No deployments
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.

uv add --index ... adds implicit indexes to files which are not consulted for them

2 participants