Skip to content

Fix hosted uv missing uv<0.5.6 advisories (#1569) - #1609

Open
Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
mainfrom
agent/fix-uv-hosted-old-uv-advisory
Open

Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
mainfrom
agent/fix-uv-hosted-old-uv-advisory

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Fixes #1569

Summary

A hosted uv scan can wire the patched package in two ways that uv before
0.5.5 doesn't honour:

  • Transitive package: a [tool.uv] override-dependencies entry plus a
    [tool.uv.sources] url. On old uv a plain uv sync re-resolves the
    override against the registry and silently reinstalls the unpatched
    wheel.
  • Package in constraint-dependencies: the lock's [manifest] constraints / build-constraints entry is repointed, and old uv rejects
    that under uv sync --locked.

Vendored mode already warned about both (pypi_uv_override_requires_uv_0_5_6,
pypi_uv_constraints_require_uv_0_5_6). Hosted mode warned about neither and
exited 0. Now hosted scans emit redirect_uv_override_requires_uv_0_5_6 and
redirect_uv_constraints_require_uv_0_5_6 when they write that wiring, for
project and PEP 723 script locks. These are advisories only: the redirect
still counts, the exit code doesn't change, and a settled re-run says nothing.

Root cause

rewrite_uv_lock (patch/redirect/mod.rs) confirms the pin without looking
at which wiring shape it used, so the uv-version advisories that
vendor/pypi_uv.rs emits for the same shapes had no hosted equivalent.

Changes

  • rewrite_uv_lock: once a dep is confirmed and this run changed its
    wiring, check whether the paired pyproject/script reaches it through an
    override (a marked entry or the user's own) and whether the lock's
    [manifest] constrains it. The constraints check reads the lock session's
    existing parsed document, so the lock isn't parsed again.
  • Hosted and vendored share one advisory text (utils/python_script.rs).
    The text now gives the measured affected range (uv before 0.5.5, per
    docs/testing/uv-compatibility.md) and keeps the documented >= 0.5.6
    advice. Before, the constraints text said only 0.2.37–0.5.3 were affected,
    but 0.5.4 rejects the entry too.
  • UV_OLD_RELEASE_ADVISORIES: excluded from the "see the warning below"
    count and from the takeover's skip-reason lookup, because they describe a
    pin that landed.
  • CLI_CONTRACT.md row and uv-compatibility.md notes.

Test evidence

  • New patch::redirect::uv_old_release_advisories tests: transitive
    override (LF and CRLF), repointed constraint, a user-written override
    under a non-canonical Six grant, script-lock override, and a silent
    direct dependency. Before the fix: 3 failed (left: [], expected the
    code). After the fix: all pass.
  • python_lock_rewrite.golden re-blessed. To check it, I filtered out the
    two new codes in the harness and matched the previous golden exactly
    across all 1500 seeded cases. The sweep now has to reach both codes.
  • tests/uv_hosted.rs: the transitive case expects the override advisory.
  • Real uv 0.12.17, cargo test -p socket-patch-cli --all-features --test e2e_redirect_uv_build -- --ignored: 9/9 pass. The hosted transitive and
    constraints lanes now assert their advisory, and every other lane asserts
    that neither code appears.
  • cargo fmt --all -- --check and cargo clippy --locked --workspace --all-features -- -D warnings: clean. cargo test -p socket-patch-cli --lib: 921 pass.
  • Full cargo test --workspace --all-features --no-fail-fast: the only
    failures were tests that can't pass in this sandbox, which runs as root
    with no route to patches-api.socket.dev: chmod-based write-failure tests
    (poetry/requirements wire rollback, repair cleanup, vlt heal, copy_tree
    symlink) and the network-backed e2e_bun_lockb rollback. None of them
    touch uv. CI runs them as non-root.

Per-issue checklist

Bugbot

  • Takeover explain could name a uv advisory as a package's skip reason through the names_package pass. Fixed in 21f5d28 with the regression test uv_old_release_advisories_never_explain_a_skip, which goes red to green.

Review notes (/code-review high)

Fixed: user-written overrides were missed, takeover skip-reason list,
wrong version range in the text, non-canonical name, an extra lock parse,
duplicated text, and the e2e absence check. Not changed: re-emitting on a
re-pin to a superseding patch. That run rewrites the same fragile wiring, so
the advisory still applies; the contract now says so.

🤖 Generated with Claude Code


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
A hosted uv scan wires a transitive patched package through a marked
override-dependencies entry, and repoints [manifest] constraints in
uv.lock. uv before 0.5.5 honours neither: a plain uv sync silently
reinstalls the unpatched wheel, or uv sync --locked fails. Vendored
mode already warns about both; hosted printed nothing and exited 0.

Hosted scans now emit redirect_uv_override_requires_uv_0_5_6 and
redirect_uv_constraints_require_uv_0_5_6 on the run that wires those
shapes (project and script locks). They advise only: the redirect
still counts and the exit code is unchanged.

Fixes #1569

Assisted-by: Claude Code:claude-opus-5-5
Re-bless the uv rewrite golden: the only change in its 1500 seeded
cases is the new advisory (verified by filtering those two codes and
matching the previous golden exactly), and require that the sweep
reaches both codes. The real-uv hosted transitive and constraints
lanes now assert the advisory, and the uv_hosted transitive case
expects it.

Refs #1569

Assisted-by: Claude Code:claude-opus-5-5
Review fixes for the hosted uv advisories:

- A user's own override-dependencies entry, which the hosted rewrite
  reuses for its source, now gets the advisory too: old uv ignores the
  source there just the same.
- Read the [manifest] constraints from the lock session's document
  instead of parsing the lock again per package.
- Hosted and vendored now share one advisory text, which names the
  real affected range (uv before 0.5.5) and the canonical name.
- Vendored-to-hosted takeover no longer names a uv advisory as the
  reason another package stayed vendored.

Refs #1569

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 16, 2026 14:07
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a 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.

Stale Bugbot comment from a previous run.

Comment thread crates/socket-patch-cli/src/commands/scan/hosted/takeover.rs
The takeover's skip explanation matched a warning that names the
package before it filtered out landed-pin advisories, so a package
named like a word in the uv advisory (wheel, uv, sync) could inherit
another pin's advisory as its reason for staying vendored. Filter the
uv advisories out of both passes.

Refs #1569

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 21f5d28. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 16, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Ready for review at 21f5d28: CI 35/35 green (19 skipped), no conflicts, Bugbot reviewed this head with no findings and the one earlier review thread is resolved. Reviewers: the new hosted advisories redirect_uv_override_requires_uv_0_5_6 / redirect_uv_constraints_require_uv_0_5_6 are warnings only and don't change exit codes.


Generated by Claude Code

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] I verified this PR (head 21f5d28) against real uv 0.5.3 and 0.13.1 on Linux with the bughunt mock patch server, comparing it with main 657fce2:

Lane main hosted PR hosted vendored (both)
transitive six (isodate) none redirect_uv_override_requires_uv_0_5_6 pypi_uv_override_requires_uv_0_5_6
six direct + constraint-dependencies none redirect_uv_constraints_require_uv_0_5_6 pypi_uv_constraints_require_uv_0_5_6
transitive + constraint none both codes both codes
direct six none none none
  • An idempotent re-scan is silent in every lane.
  • H→V and V→H takeovers on 0.5.3 each emit the advisory for the new mode.
  • On 0.5.3, uv sync --locked exits 2 and a plain sync rewrites the lock and installs unpatched six, matching the advisory text. On 0.13.1 both stay patched.

No issues found.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

3 participants