Composer vendored repair (and re-vendor) rebuilds a deleted uuid dir without its socket-patch.vendor.json marker, leaving git showing the marker as deleted
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 90/100
Hướng nghiên cứu
Bắt đầu tại crates/socket-patch-core/src/vendor/composer_lock.rs:311-345 và so sánh hành vi rebuild với crates/socket-patch-core/src/vendor/cargo.rs:928-940. Dùng test_wired_missing_copy_rebuilds_artifact_only trong composer_lock.rs làm test khởi đầu; được xem là hoàn tất khi một thư mục uuid bị xóa rebuild cả artifact và marker socket-patch.vendor.json của nó.
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 Composer bug-hunt routine (ledger #321).
Summary
When a vendored Composer unit's uuid dir (.socket/vendor/composer/<uuid>/) is missing, for example because a checkout lost it or someone deleted it, socket-patch repair and a re-run of vendor download the patched copy again. Neither writes back the unit's socket-patch.vendor.json marker. The rebuild then reports success, but git status shows the marker as deleted. Committing that "repair" leaves the vendored unit without the marker that CLI_CONTRACT.md says every unit carries. Later vendor and repair runs (already_vendored, success []) never put it back.
The Cargo backend handles the same rebuild path correctly: it restores the marker when it's missing (crates/socket-patch-core/src/vendor/cargo.rs:928-940, pinned by test_wired_deleted_uuid_dir_rebuild_restores_marker). The Composer artifact-only rebuild branch doesn't.
Impact
Low. The install itself is fine: composer install from the repaired tree installs the patched bytes, and vex never reads the marker. But the repair leaves the committed vendored unit incomplete. External tools that rely on the marker ("belt-and-braces for tools that have the tree but not the lockfile") lose it, and the repair diff a user is asked to commit contains a surprise deletion.
Repro (Linux, Composer 1.10.28 and 2.10.3, PHP 8.3, main 61cfb9b)
The patch service is a local mock: POST /v0/orgs/acme/patches/package returns a granted result with an sha512 SRI, and GET serves a single-top-dir dist zip of the patched package. A manifest plus blob is staged under .socket/ for pkg:composer/acme/[email protected], from an inline package repository with a file:// zip dist.
composer update -n # installs acme/tool 1.0.0
printf '/vendor/\n' > .gitignore
git init -q && git add -A && git commit -qm init
socket-patch vendor --json --cwd . --api-url http://127.0.0.1:8765 --api-token fake --org acme
git add -A && git commit -qm vendored
git ls-files .socket/vendor | grep vendor.json
# .socket/vendor/composer/4d5e6f7a-…/socket-patch.vendor.json <- committed
rm -rf .socket/vendor/composer/4d5e6f7a-8b9c-4a1b-8c2d-0123456789ab
socket-patch repair --cwd . --api-url http://127.0.0.1:8765 --api-token fake --org acme
# Redownloaded pkg:composer/acme/[email protected] (.socket/vendor/composer/4d5e6f7a-…/acme/[email protected])
# Repair complete.
git status --short
# D .socket/vendor/composer/4d5e6f7a-8b9c-4a1b-8c2d-0123456789ab/socket-patch.vendor.json
socket-patch vendor --json --cwd . … # -> already_vendored
socket-patch repair --json --cwd . … # -> success, events: []
git status --short # marker still deleted
A vendor re-run instead of repair takes the same path. The JSON shows rebuilt with reason: vendor_artifact_missing, redownloaded: true, and the marker is still missing afterwards.
Expected vs actual
- Expected: CLI_CONTRACT.md ("Each vendored unit also carries an informational
socket-patch.vendor.jsonmarker … next to the artifact").repair"redownload[s] missing/corrupt vendored artifacts". The doc comment onwrite_marker_or_warn(crates/socket-patch-core/src/vendor/state.rs:808-812) says "Every backend's fresh and rebuild paths report it through here". After the rebuild the unit should be complete again (copy + marker), as it is for Cargo. - Actual: only the copy under
<uuid>/acme/[email protected]/is recreated. The marker stays deleted for good.
Matrix
| OS | Composer | Reproduces |
|---|---|---|
| Linux | 1.10.28 (PHP 8.3) | yes |
| Linux | 2.10.3 (PHP 8.3) | yes (×2) |
| macOS / Windows | n/a | untested. The code path is pure Rust filesystem logic, independent of OS and Composer version. |
First bad version: not a regression. v4.0.0 behaves the same way (rebuilt, marker left deleted).
Suspect code
crates/socket-patch-core/src/vendor/composer_lock.rs:311-345: the "Wired but the committed copy is missing/stale: rebuild the ARTIFACT only" branch calls composer_service_copy and mirror_filters::heal_or_warn, then returns. It never calls write_marker_or_warn, which only runs on the fresh path (composer_lock.rs:437-439). Porting Cargo's "restore the marker only when it is missing" block (cargo.rs:928-940) into this branch should fix it. test_wired_missing_copy_rebuilds_artifact_only (composer_lock.rs:1643) could assert the marker as well.
No probe runs: this is OS-independent.
- Ngôn ngữ chính
- Rust
- Star
- 8
- Fork
- 0
- Merge trung bình
- 1 ngày 7 phút
- Pull request đã merge (30 ngày)
- 178
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
-
Hosted yarn classic pins give no berry-migration warning, so a yarn 2+ install silently drops them (vendored warns about the same trap)Có thể đã có người làm @mikolalysenko đã nhận 1 ngày trước. Đang mởagent:claimed agent:triaged bug bughunt pm:yarn-classic priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
SocketDev/socket-patch#907 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
vendor --check fails a vendored package whose lock is contested by a sibling package-lock.json with "no lockfile or config references .socket/vendor/… any more", which is false, and its remedy ("re-run socket-patch vendor") is a no-op, so the check stays red foreverCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởagent:triaged bug bughunt pm:npm priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
SocketDev/socket-patch#900 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:bundler priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
SocketDev/socket-patch#896 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
SocketDev/socket-patch#783 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:pipenv priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
SocketDev/socket-patch#744 · 1 bình luận ·
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ự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
vercel-labs/agent-browser#2063 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
agent/sec-check hive/hive-school-tunaos security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Sovereign-Labs/sovereign-sdk#3070 ·