Skip to content

A rolled-back vendor eject prints "Vendored 1 package" and "Commit .socket/vendor/" with no eject_rolled_back warning, and --json still reports the rolled-back package as applied #1005

Closed

Description

[agent] Found by the scheduled npm bug-hunt routine (ledger #302).

Summary

socket-patch vendor over a hosted project (the eject) is all-or-nothing. If any pin fails, the snapshot is restored and the project stays hosted. That rollback itself works: the lock, .npmrc and the rest of the tree are byte-identical afterwards, and no .socket/vendor/ is left behind. The report is wrong, though:

  • Human output: it prints Vendored 1 package; 1 failed. and then "Next steps: 1. Commit .socket/vendor/ and the updated lockfiles … 2. Run npm install … then run socket-patch vex". But nothing was vendored, .socket/vendor/ doesn't exist, and the lockfile wasn't updated. The documented eject_rolled_back warning ("the project is still hosted, exactly as before") is never printed. The only clue is exit 1 plus the one Error: line for the pin that failed.
  • --json: warnings[] does carry eject_rolled_back. But events[] still holds {action: "applied", purl: "pkg:npm/left-pad@1.3.0"} plus a vendor_prebuilt_downloaded event, and summary.applied is 1, for a package that was rolled back and is still hosted.

Impact

A user reading the human output believes one package is now vendored and is told to commit .socket/vendor/ and reinstall. In reality the eject was undone and every package is still hosted. JSON consumers that count summary.applied or action: "applied" events (the usual way to read the envelope) record a vendored package that doesn't exist. This is the same class of misleading success text as #898, reached through the eject rollback instead of the symlinked-lock refusal.

Repro (Linux, main 859a279, local mock patch API serving left-pad@1.3.0 and ms@2.1.3)

Any per-pin failure during the eject triggers it. Here the patch service returns HTTP 500 for the ms artifact. A vendor_workspace_member refusal (#688) on one of two pins gives the same output.

mkdir p && cd p && git init -q
echo '{"name":"p","version":"1.0.0","private":true,"dependencies":{"left-pad":"1.3.0","ms":"2.1.3"}}' > package.json
npm i && echo node_modules > .gitignore && git add -A && git commit -qm i
socket-patch scan --mode hosted --yes <api flags>     # both pinned, .npmrc allow-remote=all
git add -A && git commit -qm hosted

# make the ms artifact download fail (mock returns 500), then eject:
socket-patch vendor --yes <api flags>; echo $?
#   Ejecting 2 hosted packages into .socket/vendor/...
#   Error: Failed to vendor pkg:npm/ms@2.1.3: patch service request failed: vendor package download failed with status 500: {"error": "boom"}
#   Vendored 1 package; 1 failed.
#   Next steps:
#     1. Commit .socket/vendor/ and the updated lockfiles to make the patches portable.
#     2. Run `npm install` to update the installed tree (...), then run `socket-patch vex` to verify the installed patches.
#   exit 1
git status --short        # clean: still hosted (correct)
ls .socket/vendor         # No such file or directory

socket-patch vendor --json --yes <api flags>
#   status: partialFailure, summary: {applied: 1, failed: 1}
#   events: [applied left-pad, skipped left-pad vendor_prebuilt_downloaded, failed ms apply_failed]
#   warnings: [{code: eject_rolled_back, detail: "... the project is still hosted, exactly as before"}]

Expected vs actual

  • Expected (CLI_CONTRACT.md, "vendor" eject, step 4): "If any package then fails, exactly the files the eject wrote are put back … the project stays hosted exactly as before … with the eject_rolled_back warning and partial_failure, exit 1." The human run should print that warning, and it shouldn't claim a package was vendored or tell the user to commit .socket/vendor/. The JSON shouldn't count a rolled-back package as applied. Mark it rolled back / failed, or at least don't count it in summary.applied.
  • Actual: the human path prints the vendored backend's success summary and next steps from before the rollback, and never prints the rollback. The JSON keeps the pre-rollback applied event and count.

Matrix (Linux)

npm (Node 22) trigger human: rollback warning shown human: "Vendored 1 package" + "Commit .socket/vendor/" JSON summary.applied tree after
10.9.4 ms artifact HTTP 500 (x2) no yes 1 still hosted (correct)
8.19.4 ms artifact HTTP 500 (x2) no yes 1 still hosted (correct)
10.9.4 / 12.2.0 (Node 24) left-pad refused vendor_workspace_member (#688 shape) no yes 1 still hosted (correct)

The eject is new in v5 (unreleased), so there's no released version to bisect against. The logic doesn't depend on the OS, so I didn't run a macOS / Windows probe.

Suspect code

  • crates/socket-patch-cli/src/commands/vendor.rs:1776-1783: on snapshot.restore(..) success, eject_rolled_back is pushed only onto env.warnings. Unlike the eject_rollback_failed branch right below it, nothing is printed for a human run.
  • crates/socket-patch-cli/src/commands/vendor.rs:1733-1745: VendoredBackend::apply has already printed its "Vendored N packages" summary and "Next steps", and recorded the applied events and counts, before the rollback runs. Nothing retracts them when the snapshot is restored.

Backlog review — 2026-10-08

Priority: P1 → P2. Eject rollback restores the underlying files; emitted success/counters are misleading. Keep the reporting fix.

Activity

  1. added
    bug
    bughunt
    on Oct 7, 2026
  2. mikolalysenko commented on Oct 7, 2026

    @mikolalysenko
    CollaboratorAuthor

    Being fixed in draft PR #1008 (batch fix for open pm:npm issues).

  3. mikolalysenko commented on Oct 7, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triage: priority:p1. npm. Already being fixed in draft #1008.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedbugbughuntpm:npmpriority:p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions