Repository navigation
Fix mirror archiveUrl dropped on berry restore (#1465) - #1466
Mikola Lysenko (mikolalysenko) merged 4 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Behind a registry mirror that passes npmjs metadata through, tarball URLs still point at registry.npmjs.org. Yarn berry binds those with ::__archiveUrl= and pnpm records them as tarball:, because each compares only against the package's own registry. Hosted rollback and remove treated an npmjs-conventional URL as derived whatever the project's registry, so they dropped the binding and the next cold install fetched a path the mirror 404s. The derived check now compares only against the project's registry when the version document came from it. The default registry still counts when the project resolves from it, or when the mirror could not be read and its document was a fallback guess. Fixes #1465 Assisted-by: Claude Code:claude-opus-5-5
Real yarn 4 behind a mirror that passes npmjs packuments through binds the dependency to its npmjs tarball with ::__archiveUrl=. The new e2e pins it hosted, rolls back, checks the restored lock carries yarn's own binding, and runs a cold immutable install behind the mirror, which 404s on the conventional mirror path if the binding is lost. Refs #1465 Assisted-by: Claude Code:claude-opus-5-5
Skip the default-registry lookup when the document came from the project's registry, read the dist once in the berry restore, and add a unit test that npmjs tarballs recorded behind a mirror are no longer read as proof that lockfile-include-tarball-url is on. Refs #1465 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit bbc9ccf. Configure here.
|
Labeled Ready for review by the burn-down agent.
Generated by Claude Code |
Final review briefWhat it does. Behind a registry mirror that passes npmjs metadata through unchanged (tarball URLs still on registry.npmjs.org), hosted Risk: low. One predicate in Look here
Verified
Changes I made: none. Open questions: none blocking. The author lists declined Auto-merge is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #1465
Summary
Some projects sit behind a registry mirror that passes npmjs metadata through unchanged, so the tarball URLs still point at registry.npmjs.org. In those projects, hosted
rollbackandremovedropped yarn berry's::__archiveUrl=binding (and pnpm'starball:) while exiting 0. The next cold install then fetched the conventional path under the mirror, which 404s (YN0035). After this PR the restore writes back what the package manager itself wrote.Root cause
registry_derives_tarball(crates/socket-patch-core/src/patch/redirect/upstream/npm.rs) decides whether the package manager derives a tarball URL itself and so leaves it out of the lock. It accepted a URL that was conventional under either the project's registry ornpm_registry_base()(npmjs, orSOCKET_NPM_REGISTRY). Yarn (isConventionalTarballUrlviagetScopeRegistry) and pnpm compare only against the package's own registry. So an npmjs URL served by a mirror was wrongly treated as derived.The same helper drives three call sites, and the fix covers all of them:
npm:locator restore (berry_registry_locator)tarball:restorelockfile-include-tarball-urlFix
registry_derives_tarballnow takesfrom_project, which says whether the version document was read from the project's own registry (ProjectDist::from_project).SOCKET_NPM_REGISTRYstands in for npmjs), and the mirror could not be read so its document is the fallback guess.The lock-evidence path reads no document, so it uses
non_default_registry, the same testfetch_dists_onuses to decide whether to read the project registry.Tests (red → green)
rollback+remove, top-levelnpmRegistryServermirrorin_process_redirect::yarn_berry_unwind_keeps_a_default_registry_url_behind_a_mirror--immutable --check-cacheinstall succeedse2e_redirect_yarn_berry_build::berry_hosted_rollback_keeps_archive_url_behind_passthrough_mirrornpmScopesform / scoped namenpm::tests::project_registry_decides_a_mirrors_tarball_urls(scoped@s/pbehind a mirror), with scope-registry lookup already covered by #1017 testsnpm.rs:1846)in_process_redirect::pnpm_rollback_keeps_a_default_registry_tarball_behind_a_mirrortarball:dropped)npm.rs:1484)npm::tests::npmjs_tarballs_behind_a_mirror_are_no_tarball_setting_evidencenpm::tests::berry_locator_binds_only_an_underived_tarballCommands run locally:
cargo fmt --all -- --check: okcargo clippy --workspace --all-features -- -D warnings: okcargo test -p socket-patch-core --all-features --lib: 6407 pass. 4 fail only as root (chmod-based write-failure tests) and pass as an unprivileged user.in_process_redirect: 142 pass. 3 fail only as root, same as above, and pass as non-root.in_process_rollback_hosted38/38,hosted_memory_engine39/39.SOCKET_PATCH_YARN_E2E_REQUIRED=1, yarn 4.18.0):e2e_redirect_yarn_berry_build35/35,e2e_vendor_yarn_berry_build39/39,e2e_yarn4_pnpm_linker_build38/38,e2e_yarn4_workspaces_build37/37.cargo test --workspacedoesn't fit this sandbox's disk, so CI covers the rest.mode_migration_npm's two berry tests can't reach npmjs through the sandbox proxy's CA from their test-sidereqwest::Client. That is unrelated to this change.No npm/pypi/gem wrapper changes are needed: the wrappers only dispatch to the binary.
Review findings not fixed
From
/code-review high:upstream_registry_fallbackalready warns, and the Hosted pnpm rollback/remove restorespnpm-lock.yamlfrom npmjs's version document instead of the project's.npmrcregistry, so a mirror project loses itstarball:URL (cold frozen install 404s) or is moved to npmjs #919 fallback test pins this behaviour.SOCKET_NPM_REGISTRYcounted on the evidence path. It stands in for npmjs throughout this module (non_default_registry,fetch_dists_on). The behaviour is unchanged from main.ProjectDistinstead of a bool. It's a reasonable refactor, but it's wider than this fix.curl. The test-sidereqwestclient uses webpki roots only, so it fails behind TLS-intercepting proxies. curl ships on every CI runner OS..yarnrc.yml. The new rc repeats every key the fixture writes.🤖 Generated with Claude Code
https://claude.ai/code/session_01QT2WDJPU22ezCv8jCEUNSP
Generated by Claude Code