fix(vendor): recover pypi wheels for pdm/poetry/pipenv, not just uv - #165
Open
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Open
fix(vendor): recover pypi wheels for pdm/poetry/pipenv, not just uv#165Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Conversation
The pypi arm of `recover_lock_entry` only accepted the `uv_lock_package` wiring kind, so `repair` could not rebuild a missing vendored wheel in pdm/poetry/pipenv/pip projects even when state.json recorded the full pre-vendor registry fragment (sha256 included). It also surfaced a false diagnostic claiming the package "is not installed" and "the ledger records no recoverable registry fragment" when both were present. Accept every pypi lock-fragment kind (uv_lock_package, pdm_lock_package, poetry_lock_package, pipenv_lock_entry, requirements_line). pdm's `static_urls` locks inline the wheel URL exactly like uv.lock and now recover cleanly; the URL-less formats get an accurate, actionable message instead of the false one, and repair_vendor surfaces that precise reason rather than the blanket "no recoverable registry fragment". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mikola Lysenko (mikolalysenko)
enabled auto-merge (squash)
August 12, 2026 23:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The pypi arm of
recover_lock_entry(crates/socket-patch-core/src/vendor/lock_inventory.rs:1112, pre-fix) only accepted theuv_lock_packagewiring kind:But every other pypi package manager records the pre-vendor resolution under its own kind — pdm writes
pdm_lock_package(pypi_pdm.rs:44), poetrypoetry_lock_package(pypi_poetry.rs:40), pipenvpipenv_lock_entry(pypi_pipenv.rs:42), bare piprequirements_line(pypi_requirements.rs:452). Sorepaircould not rebuild a missing vendored wheel in a pdm/poetry/pipenv/pip project even whenstate.jsonheld the full pre-vendor fragment (sha256 included).Worse, the downstream diagnostic in
repair_vendor.rs:580(pre-fix) discarded the real reason and printed a false message — "the package is not installed ... the ledger records no recoverable registry fragment" — when the package was installed and the fragment was present (confirmed in prod: pdm +urllib3==1.26.18).Fix
crates/socket-patch-core/src/vendor/lock_inventory.rs:1112— the pypi arm now accepts all five pypi lock-fragment kinds (uv_lock_package,pdm_lock_package,poetry_lock_package,pipenv_lock_entry,requirements_line). pdm'sstatic_urlslock inlines the wheel URL exactly like uv.lock ({url = "…", hash = "sha256:…"}, see the fixture atpypi_pdm.rs:662), sopure_wheel_from_uv_unitrecovers it cleanly and repair can now fetch + verify it.{file = …}, pipenvhashesonly, pip--hash=) genuinely carry no fetchable registry URL — only uv.lock and pdmstatic_urlsdo. Those now return an accurate, actionable message ("… records the wheel hash but no fetchable registry URL … reinstall the package so repair can rebuild from the installed copy") instead of the uv-specific "no uv.lock fragment recorded".crates/socket-patch-cli/src/commands/repair_vendor.rs:574— thevendor_artifact_unrepairablepath now surfaces that preciseUnverifiablereason instead of the blanket, false "no recoverable registry fragment" text.Test
crates/socket-patch-core/src/vendor/lock_inventory.rs(recover_tests):recover_pypi_pdm_static_urls_recovers_pure_wheel— apdm_lock_packagefragment withstatic_urls(url = …) recovers the pure wheel (resolved URL + sha256). Fails before the fix: the uv-onlywiring_originalreturnsNone, sorecover_lock_entry(...).unwrap()panics.recover_pypi_urlless_locks_report_no_fetchable_url—poetry_lock_package/ default-pdm_lock_package(file = …) andpipenv_lock_entry(JSON object) now return the accurate "no fetchable registry URL" error. Fails before the fix: those kinds hit the uv-specific "no uv.lock fragment recorded" message.cargo test -p socket-patch-core --lib recover→ 12 passed.cargo test -p socket-patch-cli --lib repair→ 10 passed. Both crates build clean.Scope
pypi-ledger-recovery-uv-only-repair-unrepairable(P1).pipenv_lock_package; the actual constant ispipenv_lock_entry(pypi_pipenv.rs:42) — used here.pypi_wheel.rs). So a registry fetch is only possible for lock formats that inline the URL (uv.lock, pdmstatic_urls). For the URL-less formats repair's primary path remains the installed copy; this PR makes recovery recognize their fragments and stops the false diagnostic, but does not add a registry resolver for them.revendor-emits-misleading-uv-lock-warning-in-pdm-projectP2,rescan-skip-message-names-uvlock-in-pipenv-projectP3) live in a different code path (the vendor skip/idempotency messaging, notrecover_lock_entry) and are not touched here.repair_vendor.rs(one match arm) in addition tolock_inventory.rs; no overlap expected with other in-flight fixes.🤖 Generated with Claude Code
Note
Medium Risk
Changes PyPI vendor repair and ledger recovery behavior for non-uv projects; incorrect recovery could block repairs or misreport causes, but does not alter auth or broad install paths.
Overview
PyPI ledger recovery in
recover_lock_entryno longer only readsuv_lock_packagewiring fragments. It now accepts pdm, poetry, pipenv, and requirements pre-vendor lock kinds as well, sorepaircan rebuild missing vendored wheels whenstate.jsonstill holds those fragments (not only uv projects).For lock shapes that record a wheel hash but no fetchable registry URL (default pdm/poetry
file = …, pipenv hashes-only, pip--hash=), recovery returns an explicit message to reinstall and rebuild from the installed copy—instead of uv-specific or misleading “no recoverable fragment” text.Repair diagnostics in
repair_vendornow surfaces the precisePristineFetch::Unverifiablereason from recovery when a pristine fetch cannot proceed, rather than a blanket message that implied the ledger recorded nothing.Tests cover pdm
static_urlswheel recovery and URL-less lock error messaging across poetry/pdm/pipenv.Reviewed by Cursor Bugbot for commit 22ec0f0. Configure here.