Vendored PDM patches can never be unwound after any later PDM lock write (pdm add / pdm update / pdm lock --refresh): vendor --revert drift-keeps with exit 0, rollback and remove exit 1
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
Start in crates/socket-patch-core/src/vendor/pypi_pdm.rs at revert_pdm, then compare the Poetry fallback in crates/socket-patch-core/src/vendor/pypi_poetry.rs and the fragment splice in vendor/common.rs. Read docs/testing/pdm-compatibility.md and reproduce the reported relock with PDM; check whether the fallback restores the registry lock entry and vendored wheel. Done means vendor --revert, rollback, remove, and hosted takeover all handle the reformatted PDM lock, with regression coverage.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[agent] Found by the scheduled PDM bug-hunt routine (ledger #312).
Summary
socket-patch writes the vendored [[package]] unit of pdm.lock in its own layout: a one-line inline files = [{ ... }] with path appended after it. Any later PDM command that rewrites the lock, even one about an unrelated package (pdm add six, pdm update idna, pdm lock --refresh), re-renders that unit in PDM's layout: path moves up next to requires_python, and files becomes a multi-line array. The vendored source and the patched hash survive, so the project still installs the patched wheel. But the PDM revert (revert_pdm → revert_lock_fragment_splice) needs the recorded vendored fragment byte for byte, so from then on:
vendor --revertdrift-keeps the package (vendor_lock_entry_drifted,vendor_artifact_kept) and exits 0. The lock still points at.socket/vendor/pypi/<uuid>/.rollbackexits 1 ("Kept vendored state … lockfile wiring drifted").remove pkg:pypi/[email protected]exits 1.- The suggested remedy ("restore the vendored lock entries or re-vendor") doesn't help:
scan --mode vendoredreportsalready_vendoredand leaves the lock byte-identical, so the next revert drift-keeps again. - A vendored → hosted switch (
scan --mode hosted) skips the package withvendored_revert_failed.
The only way out is restoring pdm.lock from version control by hand, which also throws away the user's own lock change (the pdm add).
This is the PDM counterpart of #1615 (Poetry). #1662 fixed only revert_poetry (restore_re_rendered), and the PDM arm still has no fallback. A plain pdm lock (which drops the wiring) is fine: rollback then exits 0. A hosted PDM lock under the same pdm add also rolls back fine.
Impact
Every vendored PDM project that later adds, updates or relocks any dependency, which is the normal life of a project, can never unwind its patch with rollback, remove, vendor --revert or a mode switch. vendor --revert reports success while the patch stays wired in.
Repro
Run against a local mock patch API that offers one free patch for [email protected] (the Socket patch hosts aren't reachable from the sandbox). The shape matches the repo's vendored PyPI tests: /v0/orgs/<org>/patches/{batch,by-package,view,package} plus the wheel route.
mkdir demo && cd demo
cat > pyproject.toml <<'TOML'
[project]
name = "demo"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = ["urllib3==1.26.18", "idna==3.7"]
[tool.pdm]
distribution = false
TOML
pdm venv create 3.11 && pdm use -f .venv && pdm lock # PDM 2.29.7
socket-patch scan --mode vendored --yes # wires path = "./.socket/vendor/pypi/<uuid>/…whl"
pdm add six==1.16.0 # or: pdm update idna / pdm lock --refresh
socket-patch vendor --revert --yes; echo $? # 0, but "pdm.lock fragment for urllib3 changed since vendoring; left untouched"
grep '.socket/vendor' pdm.lock # still wired
socket-patch rollback --yes; echo $? # 1
socket-patch remove pkg:pypi/[email protected] --yes; echo $? # 1
socket-patch scan --mode vendored --yes --json # skipped already_vendored, lock unchanged
The re-render that pdm lock --refresh makes to the unit socket-patch wrote:
requires_python = ">=2.7, !=3.0.*, …"
+path = "./.socket/vendor/pypi/aaaaaaaa-…/urllib3-1.26.18-py2.py3-none-any.whl"
summary = "HTTP library with thread-safe connection pooling, file post, and more."
groups = ["default"]
-files = [{ file = "urllib3-1.26.18-py2.py3-none-any.whl", hash = "sha256:8a05…" }]
-path = "./.socket/vendor/pypi/aaaaaaaa-…/urllib3-1.26.18-py2.py3-none-any.whl"
+files = [
+ {file = "urllib3-1.26.18-py2.py3-none-any.whl", hash = "sha256:8a05…"},
+]
Expected vs actual
- Expected: docs/testing/pdm-compatibility.md says "Vendored rollback restores recorded fragments", and CLI_CONTRACT.md's drift-keep is meant for a lock whose wiring was actually changed. Here the lock still carries exactly the source and hash socket-patch wrote, only re-formatted by PDM. As in #1662 for Poetry,
vendor --revert,rollback,removeand the hosted takeover should restore the registry unit and reclaim the wheel. Failing that, the "re-vendor" remedy they print should at least work. - Actual: permanent drift-keep.
vendor --revertexits 0 with the patch still wired, androllback/removeexit 1.
Versions
Vendored with the PDM in the first column. The lock is then rewritten by the second.
| PDM that vendored (lock_version) | relock | socket-patch | result |
|---|---|---|---|
| 2.29.7 (4.5.1) | 2.29.7 pdm lock --refresh |
main cfc870f |
stuck (rollback exit 1) |
| 2.29.7 | 2.29.7 pdm add six==1.16.0 |
main cfc870f |
stuck |
| 2.29.7 | 2.29.7 pdm update idna |
main cfc870f |
stuck |
| 2.29.2 (4.5.1) | 2.29.2 pdm lock --refresh |
main cfc870f |
stuck |
| 2.26.9 (4.5.0) | 2.26.9 pdm lock --refresh |
main cfc870f |
stuck |
| 2.12.4 (4.4.1) | 2.12.4 / 2.29.7 pdm lock --refresh |
main cfc870f |
stuck |
| 2.29.7 | 2.29.7 pdm lock --refresh |
v5.1.0 release | stuck (not a regression) |
| 2.29.7 | 2.29.7 plain pdm lock (wiring dropped) |
main | pass (rollback exit 0) |
| 2.29.7, hosted mode | pdm add six==1.16.0 |
main | pass (rollback exit 0, lock --check ok) |
Each stuck row reproduced from a fresh project directory (Linux, Python 3.11). The revert is a text splice on pdm.lock with nothing OS-specific beyond line endings, so I expect the same on macOS and Windows; a CRLF lock may well behave the same way.
Suspect code
crates/socket-patch-core/src/vendor/pypi_pdm.rs:541revert_pdm: it only callsrevert_lock_fragment_splice(crates/socket-patch-core/src/vendor/common.rs:749, drift message atcommon.rs:860). It has no re-render fallback likerestore_re_renderedincrates/socket-patch-core/src/vendor/pypi_poetry.rs:485(#1662).- The vendored writer in
crates/socket-patch-core/src/utils/pdm_lock.rsemits a layout PDM never writes (inlinefiles,pathlast), so the first PDM write always re-renders it. Writing PDM's own layout would shrink the window, but a fallback is still needed for older or newer PDM layouts. - Related tracking: #989.
Generated by Claude Code
- Ngôn ngữ chính
- Rust
- Star
- 9
- Fork
- 2
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 313
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SocketDev/socket-patch
-
agent:triaged arch-audit bug priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
SocketDev/socket-patch#2306 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit bug priority:p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
SocketDev/socket-patch#2296 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:needs-human agent:triaged ci-janitor priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SocketDev/socket-patch#2270 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit bug priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
SocketDev/socket-patch#2259 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
SocketDev/socket-patch#1860 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SocketDev/socket-patch
Issue tương tự
-
Bash init calls `cygpath` unconditionally on Windows, which breaks non-Cygwin shells like `brush`Có thể đã có người làm @iliqiliev đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ajeetdsouza/zoxide#1381 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
triage
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
kornia/kornia-rs#1416 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
paritytech/revive#749 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
swc-project/swc-next-issues#1043 ·