Decide: what rollback owes a package when a file of its patch is missing on disk, the state apply --force leaves
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Read the --force handling in crates/socket-patch-core/src/patch/apply.rs at L1828-L1832, the rollback paths in crates/socket-patch-core/src/patch/rollback.rs at L200-L209 and L650-L658, and the rollback and --force rows in CLI_CONTRACT.md. Decide which rollback behavior the contract should promise for a missing patch file; define completion by updating the contract and implementing the chosen behavior, with tests covering the supplied fixture and forced apply followed by rollback.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[agent] Filed by the architecture refactor routine, which found this while checking #1987. Everything below was run with the binary built from main at cfc870f.
What happens
apply --force skips a patch file that is missing on disk and patches the rest (apply.rs L1828-L1832). rollback has no matching rule: one absent file stops the whole package before anything is restored (rollback.rs L200-L209, L650-L658). So no command undoes a forced apply, and a record whose package lacks one of the patch's files can never be rolled back, whether the other files are patched or not.
The fixture is files only: node_modules/left-pad 1.3.0 holding index.js, and a manifest record whose patch lists package/index.js and package/lib/gone.js, with all four blobs in .socket/blobs.
$ socket-patch apply --offline
Error: Failed to patch pkg:npm/[email protected]: Cannot apply patch: package/lib/gone.js - File not found (exit 1)
$ socket-patch apply --offline --force
Warning: pkg:npm/[email protected]: 1 patch file not found on disk and skipped (--force): package/lib/gone.js
Patched packages:
pkg:npm/[email protected] (via blob) (exit 0)
$ socket-patch rollback --offline --yes
Failed to roll back:
pkg:npm/[email protected]: Cannot roll back: package/lib/gone.js - File not found
Error: Some patches could not be rolled back. (exit 1; index.js is still patched)
$ socket-patch remove pkg:npm/[email protected] --yes --offline
Error: Failed to roll back pkg:npm/[email protected]: Cannot roll back: package/lib/gone.js - File not found
Error: Rollback failed during patch removal. Use --skip-rollback to remove from manifest without restoring files.
(exit 1)
What is left to the user:
remove --skip-rollbackdrops the record and leavesindex.jspatched.- Reinstalling the package first does not help. With
index.jsback at its upstream bytes, so that every file that exists is original,rollbackandremoveprint the same error and exit 1, with nothing left to restore. apply --checkon the forced state saysRun socket-patch apply to regenerate them. Thatapplyexits 1 with the "File not found" error above; onlyapply --forcereports the package as already patched.vexleaves the package out (file_not_found), which is the documented omission.
Why this is a decision
CLI_CONTRACT.md documents both halves. The --force row says "A file of the patch that is missing on disk is skipped instead of failing the package, and named in a patch_files_skipped warning". The rollback table says file_not_found is a failed event when "the copy's first blocking file … is missing". It does not say what rollback owes a package that apply --force patched in part, and any fix changes rollback's result for that row.
Options
rollbackrestores every file that holds the patched bytes, treats an absent file as nothing to restore, and names it in a warning, aspatch_files_skippeddoes on the way in. The run succeeds when every file that exists is original afterwards.rollbackwrites the before-blob to the absent path. That restores a file a user deleted after patching, and adds a file to an install that never had it.- Keep the refusal and say the way out. The advice printed for a hash mismatch (reinstall, then roll back again) does not work here; the only exit that works today is a reinstall followed by
remove --skip-rollback.
Which should it be? The routine opens a PR once this is answered.
Not checked
- How often a real install lacks a file its patch lists. The fixture is hand-built. A plain
applyfails on such an install, and--forceis the documented way past it. - The pnpm and vlt store-copy fan-out: a store copy's forced skip is dropped on purpose (
apply_force_skip_in_a_twin_keeps_an_already_patched_primary), and I did not run a rollback over one.
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ự
-
Find/Replace panel: "Previous/Next occurrence" labels overlap and overflow their buttons (French)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/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
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 62/100
obi1kenobi/cargo-semver-checks#1839 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
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