`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 天内回复
已经有一个关联 PR 被合并了。
- #1325 来自 @mikolalysenko —— 已合并
评估
调研方向
错误的修复方式是 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
- 平均合并
- 19 小时 44 分钟
- 30 天内合并 PR
- 450
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged bug bughunt pm:npm priority:p3
难度 2/5 1-3 小时 新手友好度 75/100
SocketDev/socket-patch#1072 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:bundler priority:p1
难度 2/5 1-3 小时 新手友好度 85/100
SocketDev/socket-patch#896 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
难度 2/5 1-3 小时 新手友好度 73/100
SocketDev/socket-patch#783 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:triaged bug bughunt pm:cargo priority:p2
难度 2/5 1-3 小时 新手友好度 84/100
SocketDev/socket-patch#651 · 3 条评论 ·
维护者通常 1 天内回复
-
CI perf: e2e-build-windows — full Windows test build is the merge-queue critical path in 27/30 runs (~2.5 min off every merge)可能已有人在做 @mikolalysenko 今天认领。 未关闭agent:claimed agent:triaged ci-perf priority:p3
难度 3/5 1-2 天 新手友好度 30/100
SocketDev/socket-patch#1385 · 2 条评论 ·
维护者通常 1 天内回复
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 63/100
metasequoiaime/msime#7328 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
eclipse-opensovd/classic-diagnostic-adapter#616 ·
维护者通常 2 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 86/100
维护者通常 1 天内回复
-
track: content
难度 2/5 1-3 小时 新手友好度 72/100
0xAndersen/witness-log#10 ·
-
follow-up main-defect wave-A
难度 2/5 1-3 小时 新手友好度 72/100
carrick-sh/carrick#249 ·
维护者通常 1 天内回复