`apply --check` drift report tells you to run `socket-patch apply` without the `-g` / `--global-prefix` / `--cwd` it was given, so following it patches nothing and exits 0
維護者通常 1 天內回覆
評估
研究方向
錯誤的修復方式是 crates/socket-patch-cli/src/commands/apply.rs 中 run_check 內、約第 674 行處寫死的 eprintln!,它忽略了 args.common(global、global_prefix、cwd、manifest_path、ecosystems)。請以 #777 修復中 scan -g 使用的 report_only_hint 輔助函式為範本,並用相同的範圍參數建構 apply 指令。當輸出的修復指令在 issue 的重現步驟之後原樣執行,能夠修復副本,且之後的 apply --check 以結束碼 0 結束時,即為完成。
由索引模型根據 Issue 內容生成。
描述
[agent] Found by the scheduled Pipenv bug-hunt routine (ledger #313).
Summary
When apply --check finds drift, the human report always ends with the fixed line:
Error: Patches are OUT OF SYNC:
pkg:pypi/[email protected]: patch not applied (an installed copy is still unpatched)
Run `socket-patch apply` to regenerate them.
The suggested command drops every scope flag the check ran with. The check itself is correct (exit 1 on the stale copy), but running the remedy as printed targets a different tree:
apply --check -g --global-prefix <site-packages>(the Dockerpipenv install --systemshape): plainsocket-patch applycrawls the cwd project, prints0 of 1 targeted patch applied, … 1 not found on disk, and exits 0. The global copy stays unpatched.apply -gwithout the prefix patches the default system interpreter instead. In the sandbox that was the distro's/usr/lib/python3/dist-packages/six.py, which isn't the tree that was checked.apply --check --cwd app(CI running from a parent directory): plainsocket-patch applyprintsNo patch manifest found; nothing to apply.and exits 0. The Pipenv venv stays unpatched.
This is the same class as #464 (the report-only scan -g hint dropped -g), which was fixed in #777. The apply --check report wasn't covered by that fix.
Impact
apply --check is the CI / GitHub-App audit gate (CLI_CONTRACT apply --check row). A user or CI job that follows its remedy gets exit 0 and believes the drift is fixed. The next apply --check fails again, and the installed copy keeps running unpatched bytes in the meantime. There's no false VEX: this is a misleading remedy, not a wrong verdict.
Repro (Linux, main f3c6313, Pipenv 2026.8.0, local mock of the patch API serving a patched six-1.16.0 wheel)
# global / Docker `pipenv install --system` shape
G=$(mktemp -d)/sys; python3.11 -m venv "$G"; SPK=$G/lib/python3.11/site-packages
"$G/bin/pip" install six==1.16.0
cd my-pipenv-project # Pipfile + Pipfile.lock pinning six==1.16.0
socket-patch scan -g --global-prefix "$SPK" --mode agent --yes # patches $SPK/six.py
"$G/bin/pip" install --force-reinstall --no-deps six==1.16.0 # image rebuilt / reinstall
socket-patch apply --check -g --global-prefix "$SPK" # exit 1, "Run `socket-patch apply` to regenerate them."
socket-patch apply # the remedy verbatim: exit 0, "1 not found on disk"
head -1 "$SPK/six.py" # still the upstream bytes
# --cwd shape (agent mode, Pipenv WORKON_HOME venv)
socket-patch scan --cwd app --mode agent --yes
(cd app && pipenv run pip install --force-reinstall --no-deps six==1.16.0)
socket-patch apply --check --cwd app # exit 1, same remedy line
socket-patch apply # exit 0, "No patch manifest found; nothing to apply."
I reproduced the -g --global-prefix lane 3 times and the --cwd lane once. In both, the remedy with the original flags (apply -g --global-prefix "$SPK", apply --cwd app) heals the tree, and the next --check exits 0.
Expected vs actual
- Expected: the remedy names the command that fixes what the check just reported. That means the same scope as the check:
-g,--global-prefix <dir>,--cwd <dir>, and--manifest-path/--ecosystemswhen given. That's how #464 / #777 fixed thescan -ghint. CLI_CONTRACT'sapply --checkrow specifies theError: Patches are OUT OF SYNC:report, and its purpose is to be acted on. - Actual: a fixed string with no scope flags. Following it exits 0 and patches nothing, or patches a different interpreter (
-gwithout the prefix).
OS × version
| OS | Pipenv | Shape | Result |
|---|---|---|---|
| Linux | 2026.8.0 | apply --check -g --global-prefix (pip-installed six, install --system shape) |
reproduces (×3) |
| Linux | 2026.8.0 | apply --check --cwd app (WORKON_HOME venv) |
reproduces |
| macOS / Windows | not probed | the line is a constant string | expected to be the same |
This isn't Pipenv- or PyPI-specific: every ecosystem's apply --check goes through the same branch.
Suspect code
crates/socket-patch-cli/src/commands/apply.rs:674, in run_check: eprintln!("Run \socket-patch apply` to regenerate them.");doesn't consultargs.common (global, global_prefix, cwd, manifest_path, ecosystems). Compare report_only_hint` after #777.
- 主要語言
- Rust
- 星號
- 8
- 分支
- 0
- 平均合併
- 22 小時 30 分鐘
- 30 天內合併 PR
- 329
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
Human `scan --mode vendored --prune` silently skips the vendored GC when no remaining package has a patch, so an `npm uninstall`ed vendored entry is never reverted (exit 0), while `--json` reverts it and `vendor --check` keeps pointing at that same command可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉agent:triaged bug bughunt pm:npm priority:p2
難度 2/5 1-3 小時 新手友好度 85/100
SocketDev/socket-patch#1127 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:bundler priority:p1
難度 2/5 1-3 小時 新手友好度 75/100
SocketDev/socket-patch#1125 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:npm priority:p3
難度 2/5 1-3 小時 新手友好度 75/100
SocketDev/socket-patch#1072 · 1 則留言 ·
維護者通常 1 天內回覆
-
scan exits 1 in human output but 0 with --json when every patch query returns nothing可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉agent:triaged arch-audit bug priority:p3
難度 2/5 1-3 小時 新手友好度 85/100
SocketDev/socket-patch#1062 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged bug bughunt pm:bundler priority:p1
難度 2/5 1-3 小時 新手友好度 80/100
SocketDev/socket-patch#1056 · 1 則留言 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 5 天內回覆
-
✨ enhancement needs-discussion
難度 1/5 1 小時以內 新手友好度 85/100
-
virtio-fs (Linux passthrough): debug log in do_lookup panics the fs worker on non-UTF-8 file names可能已有人在做 @zcl-g5 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 85/100
維護者通常 2 天內回覆
-
area:docs documentation good first issue priority:low
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆