fix(hosted): honest warnings for pnpm/yarn/bun and CRLF locks - #182
Open
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Open
fix(hosted): honest warnings for pnpm/yarn/bun and CRLF locks#182Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Conversation
Warning hygiene only - no rewrite behavior changes.
- `redirect_npm_no_lockfile` fired on every pnpm/yarn/bun/Rush hosted
run because the npm rewriter warned whenever package-lock.json was
absent, ignoring the sibling lock that was successfully rewritten.
It now fires only when NO npm-family lockfile exists at all, so a
clean pnpm/yarn/bun/Rush run no longer trains users to ignore the
warnings channel where the real signals live.
- A CRLF yarn berry lock was refused as "cacheKey is `(missing)`"
even though its cacheKey IS 10c0 - the `\n\n` block grammar never
splits a CRLF file - sending Windows users chasing yarn cache
config. The refusal now names the line endings
(redirect_yarn_berry_crlf_unsupported); same fail-closed outcome.
- A CRLF pnpm-lock.yaml surfaced per-dep as a misleading
`redirect_pnpm_entry_not_found` ("no inline resolution") though the
entry exists; it now gets a dedicated redirect_pnpm_crlf_unsupported
warning naming the file, and still redirects nothing (fail-closed).
New tests pin the EXACT warning set of clean success runs (npm: empty;
pnpm: exactly the trust-lockfile caveat) at both the rewriter unit
level and the --json envelope level, plus the two CRLF diagnoses and
the sibling-lock gating (yarn-only, Rush-nested, and lockfile-less
legs). The exact-set envelope test fails on the pre-fix code.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Wenxin Jiang (Wenxin-Jiang)
approved these changes
Aug 14, 2026
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
Four warning-hygiene defects in the hosted redirect rewriters (audit 2026-08-13,
crates/socket-patch-core/src/patch/redirect/mod.rs) made the warnings channel noisy or misleading — the same channel that carries the module's real signals (berry cache refusals, entry-not-found):redirect_npm_no_lockfileon every pnpm/Rush project (mod.rs:174):rewrite_npm_lockwarned "no package-lock.json / npm-shrinkwrap.json present" whenever its own lock was absent, with no regard for the sibling pnpm-lock.yaml (root or Rushcommon/config/rush/) that was successfully rewritten. A fully green Rush hosted run always carried the bogus warning in both--jsonwarnings[]and human stderr.\n\nblock grammar, soberry_cache_keyreturned None and the refusal claimedcacheKey is `(missing)`— even though the lock's cacheKey IS10c0. Windows-checkout users were sent chasing yarn cache/compression config instead of line endings.):\n, which never matches CRLF lines, so a Windows-normalized pnpm-lock.yaml surfaced per-dep as a misleadingredirect_pnpm_entry_not_found("no inline resolution for X") though the entry exists.Concrete failing scenario:
scan --mode hosted --jsonon a pnpm-only project with one granted patch returnedredirected: 1withwarnings: ["redirect_npm_no_lockfile", "redirect_pnpm_trust_lockfile"]— a fully successful run flagged with a lockfile complaint about a file the project should not have.Fix
Warning hygiene only — zero behavior change to rewrites (CRLF locks were already never rewritten; they were only misdiagnosed).
rewrite_npm_locknow emitsredirect_npm_no_lockfileonly when NO npm-family lockfile is present at all: a siblingyarn.lock,bun.lock/bun.lockb, orpnpm-lock.yaml(root or nested Rush) suppresses it, since that lock's own rewriter carries the per-dep diagnostics (findings 1+2 are the same defect at one boundary and share this fix). A genuinely lockfile-less project still warns, unchanged.rewrite_yarn_berrydetects CRLF content before the cacheKey gate and refuses with a newredirect_yarn_berry_crlf_unsupportedwarning naming the line endings and the LF remedy — same fail-closed outcome, honest diagnosis. Placed after the__metadata:berry-detection gate, so CRLF classic locks are untouched by this code (classic CRLF handling is a separate audit lane:classic-hosted-crlf, deliberately not addressed here).rewrite_pnpm_lockskips each CRLF lock up front with a new per-fileredirect_pnpm_crlf_unsupportedwarning naming the lock path, instead of the per-dep entry-not-found; if no LF lock remains it returns before the dep loop. Mixed CRLF+LF lock sets proceed on the LF locks unchanged.New warning codes:
redirect_yarn_berry_crlf_unsupported,redirect_pnpm_crlf_unsupported— both fail-closed refusals.Testing
redirect/mod.rs): exact-empty warning set on clean npm and pnpm success;redirect_npm_no_lockfilegating across yarn-only, Rush-nested-pnpm-only, and lockfile-less projects; CRLF berry lock withcacheKey: 10c0diagnosed as exactlyredirect_yarn_berry_crlf_unsupportedwith no rewrite; CRLF pnpm v9 lock diagnosed as exactlyredirect_pnpm_crlf_unsupported(naming the file) with no rewrite.--jsonenvelope test (in_process_redirect.rs):clean_success_warning_set_is_exact_for_npm_and_pnpmpins the EXACT warning set (npm success = empty; pnpm success = exactlyredirect_pnpm_trust_lockfile). Independently verified RED against pre-fix code by the reviewer: the pre-fix envelope carried["redirect_npm_no_lockfile", "redirect_pnpm_trust_lockfile"].cargo test -p socket-patch-core --lib patch::redirect(59 passed),cargo test -p socket-patch-core --test redirect_golden(1 passed),cargo test -p socket-patch-cli --test in_process_redirect(24 passed),cargo test -p socket-patch-cli --test in_process_redirect_pnpm(3 passed).redirect_human_mode_prints_rewriter_warnings) still passes — the warning still fires when no npm-family lock exists.No skipped findings in this lane.
🤖 Generated with Claude Code
Note
Low Risk
Warning-only changes to hosted lock redirect diagnostics; rewrite behavior for LF locks is unchanged and covered by new exact-warning and CRLF tests.
Overview
Hosted redirect rewriters now emit fewer spurious warnings and clearer CRLF refusals without changing successful LF lock rewrites.
redirect_npm_no_lockfileis suppressed when another npm-family lock owns the redirect (yarn.lock,bun.lock/bun.lockb, root or nestedpnpm-lock.yaml). Projects with no npm-family lock still get the same warning.CRLF locks are rejected up front with new codes
redirect_pnpm_crlf_unsupportedandredirect_yarn_berry_crlf_unsupported(normalize to LF and re-run), instead of misleadingredirect_pnpm_entry_not_foundor berrycacheKey is (missing)diagnoses.Tests pin exact warning sets on clean npm/pnpm success (npm empty; pnpm only
redirect_pnpm_trust_lockfilefrom the CLI layer), sibling-lock gating, and CRLF messaging.Reviewed by Cursor Bugbot for commit 706e078. Configure here.