With an unreadable vendor ledger (a git merge conflict in .socket/vendor/state.json), vex says to re-run vendor, vendor exits 0 and says to run repair, and repair fails with no remedy
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start with the reported remedy messages in crates/socket-patch-cli/src/commands/vex.rs and vendor.rs, then trace the unreadable-ledger paths used by vendor, repair, and scan. Check the CLI contract mentioned in the issue for the expected non-zero behavior. Done means commands that refuse name a usable recovery step, and vendor no longer reports success while unable to read the ledger.
由索引模型根據 Issue 內容生成。
描述
[agent] Found by the scheduled npm bug-hunt routine (ledger #302).
Summary
When .socket/vendor/state.json can't be parsed, the remedies the CLI prints send the user around in a loop, and none of them fixes the ledger:
vexrefuses (exit 2,vendor_ledger_corrupt) and says "Restore it from version control or re-runsocket-patch vendor".socket-patch vendorexits 0 with only a warning: "the vendor ledger could not be read … Runsocket-patch repairto check the vendored artifacts."socket-patch repairexits 1 ("Could not read the vendor ledger: …") and gives no remedy.
scan --mode vendored, rollback and vendor --check also fail (exit 1) without saying what to do. The only thing that works is fixing the JSON by hand or restoring it from git.
The realistic way to get here is a plain git merge. Two branches each vendor a different patch, and git conflicts on state.json (add/add on the same entries map) while it auto-merges package-lock.json cleanly. After the merge, npm ci installs both patched packages, but every socket-patch command that reads the ledger fails. "Restore it from version control" doesn't help here, because neither side alone is right. The user has to merge both sides' entries by hand, and nothing says so. The closed #1072 fixed the same kind of loop for the orphan-artifact remedy, which now explains "if a git merge kept one side of state.json, merge both sides". These remedies don't.
The maintainers decided in #1072 not to rebuild the ledger automatically, so this issue only asks for remedy text that works, and arguably for vendor to exit non-zero.
Impact
- In CI, a
socket-patch vexstep fails after a routine merge. The user is told to runsocket-patch vendor, which reports success (exit 0) and changes nothing, so a CI step that runsvendorbeforevexstill fails onvex. - A user following the printed advice can't get out of the state.
Repro (npm 12.2.3 / Node 22, Linux; a local mock of the patch API serving free patches for [email protected] and [email protected])
mkdir app && cd app
echo '{"name":"app","version":"1.0.0","private":true,"dependencies":{"left-pad":"1.3.0","is-number":"7.0.0"}}' > package.json
npm install && echo node_modules > .gitignore
git init -q && git add -A && git commit -qm init
SP="socket-patch --api-url $MOCK --api-token fake --org o --patch-server-url $MOCK"
git checkout -qb a && $SP get <left-pad-uuid> --mode vendored --yes && git add -A && git commit -qm a
git checkout -q main && git checkout -qb b && $SP get <is-number-uuid> --mode vendored --yes && git add -A && git commit -qm b
git merge a # CONFLICT (add/add) in .socket/vendor/state.json; package-lock.json auto-merges
rm -rf node_modules && npm ci # exit 0, both packages patched
$SP vex --output v.json; echo $? # 2: "... Restore it from version control or re-run `socket-patch vendor`."
$SP vendor; echo $? # 0: "Warning: ... Run `socket-patch repair` to check the vendored artifacts."
$SP repair; echo $? # 1: "Error: Could not read the vendor ledger: corrupt ./.socket/vendor/state.json: key must be a string at line 4 column 1"
It also reproduces with any hand-corrupted state.json (echo '{broken' > .socket/vendor/state.json), with the same three messages.
Expected
Each command that refuses should name a step that gets the user out. For example: ".socket/vendor/state.json is not valid JSON (a git merge conflict?). Resolve it by keeping both sides' entries, or restore it with git checkout -- .socket/vendor/state.json, then re-run." vendor shouldn't exit 0 while it can't read the ledger it owns, or at least shouldn't send the user to repair, which refuses the same input. CLI_CONTRACT's vex section treats a corrupt vendor ledger as a failure ("a corrupt vendor ledger … exits non-zero"), and the remedy text is the user's only guide.
Actual
The remedies loop: vex → vendor (exit 0) → repair (exit 1, no remedy).
| Build | npm | Reproduces |
|---|---|---|
main cfc870f |
12.2.3 | yes (merge conflict and hand-corrupted) |
| v5.1.0 | 12.2.3 | yes (same messages; not a regression) |
This isn't specific to npm: the ledger and these messages are shared by every vendored ecosystem. It should behave the same on macOS and Windows.
Suspect code
crates/socket-patch-cli/src/commands/vex.rs:2473: "… or re-runsocket-patch vendor."crates/socket-patch-cli/src/commands/vendor.rs:2678(no_manifest_ledger_unreadable): the warning, exit 0, "Runsocket-patch repair".crates/socket-patch-cli/src/commands/vendor.rs:755:Could not read the vendor ledgerwith no remedy (used byrepair/scan).
Generated by Claude Code
- 主要語言
- Rust
- 星號
- 9
- 分支
- 2
- 平均合併
- 1 天 8 小時
- 30 天內合併 PR
- 313
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged arch-audit bug priority:p2
難度 2/5 1-3 小時 新手友好度 84/100
SocketDev/socket-patch#2306 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit bug priority:p3
難度 2/5 1-3 小時 新手友好度 88/100
SocketDev/socket-patch#2296 ·
維護者通常 1 天內回覆
-
agent:needs-human agent:triaged ci-janitor priority:p1
難度 2/5 1-3 小時 新手友好度 72/100
SocketDev/socket-patch#2270 · 3 則留言 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit bug priority:p1
難度 2/5 1-3 小時 新手友好度 82/100
SocketDev/socket-patch#2259 ·
維護者通常 1 天內回覆
-
agent:triaged arch-audit priority:p3 refactor
難度 2/5 1-3 小時 新手友好度 83/100
SocketDev/socket-patch#1860 ·
維護者通常 1 天內回覆
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
Find/Replace panel: "Previous/Next occurrence" labels overlap and overflow their buttons (French)未關閉
難度 2/5 1-3 小時 新手友好度 63/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
obi1kenobi/cargo-semver-checks#1839 · 3 則留言 ·
維護者通常 1 天內回覆
-
Bash init calls `cygpath` unconditionally on Windows, which breaks non-Cygwin shells like `brush`可能已有人在做 @iliqiliev 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
ajeetdsouza/zoxide#1381 ·
維護者通常 5 天內回覆
-
triage
難度 1/5 1-3 小時 新手友好度 88/100
kornia/kornia-rs#1416 · 1 則留言 ·
維護者通常 2 天內回覆