fix(scan): warn to run pnpm install --trust-lockfile after a hosted pnpm redirect - #159
Merged
Mikola Lysenko (mikolalysenko) merged 1 commit intoAug 12, 2026
Conversation
…irect When `scan --mode hosted` rewrites a pnpm-lock.yaml it repoints tarball URLs at patch.socket.dev. pnpm >=11's lockfile supply-chain policy then rejects the lock with ERR_PNPM_TARBALL_URL_MISMATCH until the user opts in with `pnpm install --trust-lockfile`. Push a `redirect_pnpm_trust_lockfile` warning (JSON warnings[] + stderr) whenever the rewrite lands in any pnpm-lock.yaml, mirroring the existing redirect_* warnings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mikola Lysenko (mikolalysenko)
enabled auto-merge (squash)
August 12, 2026 23:41
Wenxin Jiang (Wenxin-Jiang)
approved these changes
Aug 12, 2026
Mikola Lysenko (mikolalysenko)
deleted the
fix/pnpm-hosted-trust-lockfile-warning
branch
August 12, 2026 23:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
scan --mode hostedrewrites apnpm-lock.yaml, it repoints tarball URLs atpatch.socket.dev. pnpm >=11 added a lockfile supply-chain policy that compares each resolution's tarball URL against the registry's published metadata and REJECTS the lockfile:The documented opt-out is
pnpm install --trust-lockfile(which installs the patched artifact cleanly), butscan --mode hostedemitted NO warning naming it — unlike the redirect warnings it already produces for other post-rewrite install caveats (Rushredirect_rush_repo_state_stale, the bun-migration warnings,record_fetch_failed). The production e2e sweep already documents this as a known compat gap (crates/socket-patch-cli/tests/e2e_hosted_production.rs:995-1023).Fix
crates/socket-patch-cli/src/commands/scan/hosted.rs:346-370— after the rewrite, when any rewritten file's basename ispnpm-lock.yaml(the plain root lock OR a Rush nested/subspace lock), push aredirect_pnpm_trust_lockfilewarning into the same warnings channel the neighboringredirect_*warnings use. It is surfaced in both the JSONwarnings[]array (hosted.rs:513) and human-mode stderr (hosted.rs:576-578), consistent with the rush/migration/record warnings.The warning names
ERR_PNPM_TARBALL_URL_MISMATCHand instructs the user to runpnpm install --trust-lockfile.Test
crates/socket-patch-cli/tests/in_process_redirect.rs—pnpm_lock_redirect_warns_to_trust_lockfile(hermetic, wiremock, subprocess so--jsonwarnings[]can be read back). Two legs mirroring the rush gating test: a pnpm root-lock project assertsredirected == 1, theredirect_pnpm_trust_lockfilecode is present, and its detail names--trust-lockfile; the npm-only twin (package-lock.json) rewrites identically but emits no such warning. Confirmed RED before the fix (got warnings ["redirect_npm_no_lockfile"]), GREEN after.cargo build -p socket-patch-clisucceeds;in_process_redirect(23) +in_process_redirect_pnpm(3) all pass.Scope
Single warning addition in
scan::hosted+ one regression test. No behavior change to the rewrite itself. Kills sweep findingpnpm11-hosted-policy-reject-no-warning(K2, P2). No cross-dependencies with the other parallel fixes.🤖 Generated with Claude Code
Note
Low Risk
Warning-only change in scan hosted mode; no change to lockfile rewrite logic or install behavior.
Overview
Hosted
scan --redirectnow emitsredirect_pnpm_trust_lockfilewhen a rewrite actually changes anypnpm-lock.yaml(root or Rush nested/subspace locks). The message explains that pnpm ≥11 can fail withERR_PNPM_TARBALL_URL_MISMATCHafter tarball URLs are repointed topatch.socket.dev, and tells users to runpnpm install --trust-lockfile.The warning is merged into the same JSON
warnings[]channel and human stderr as the existing Rush and migration redirect caveats. npm-only projects that only touchpackage-lock.jsondo not get it.A hermetic subprocess test asserts the warning code,
--trust-lockfilein the detail, and that npm-only redirects stay silent.Reviewed by Cursor Bugbot for commit 3f74174. Configure here.