Skip to content

Hosted Bun run with --patch-mirror-url gives no redirect_mirror_pin_not_moved for a bun.lockb pin and says an earlier patch-server pin "stays UNPATCHED" #2279

Backlog

Description

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

Summary

The patch mirror is experimental (added in #2180, not in v5.1.0), so this is not a regression. Take a Bun project that an earlier hosted run pinned directly on the patch server, and run hosted mode with --patch-mirror-url / SOCKET_PATCH_MIRROR_URL:

  1. bun.lockb: the redirect_mirror_pin_not_moved warning never fires. The run exits 0 with success, leaves the pin on the patch server, and doesn't say why or what to do. The next bun install --frozen-lockfile still downloads from the patch server's host, not the mirror. A build that may only reach the internal artifact host (the reason the mirror exists) then fails, and nothing in the run's output pointed there.
  2. bun.lock and bun.lockb: the run also prints a false redirect_bun_non_registry_entry_skipped warning. It treats socket-patch's own earlier patch-server pin as a user URL tarball: "installs minimist@1.2.8 from a URL or local tarball … so that copy stays UNPATCHED; depend on the registry release to patch it". That copy is patched. "Depend on the registry release" is not a remedy: the dependency already is the registry release. The run also counts the patch as not applied ("1 vulnerability left to patch: 1 is in packages this run did not patch"), because this branch puts the uuid into bundled_skipped_uuids. On bun.lock this false warning sits next to the correct redirect_mirror_pin_not_moved, and the two contradict each other. On bun.lockb it is the only warning, so it's the only guidance the user gets.

Impact

An Enterprise user moving an existing hosted Bun project onto their mirror is told everything succeeded, or is given a wrong remedy. With bun.lockb, their locked-down CI then fails to fetch the patch-server URL. With bun.lock they get the right remedy, but next to a warning saying the patch isn't applied.

Repro (offline: a local mock patch API on :18080 and a mirror on :18081)

The mock serves /v0/orgs/o/patches/{batch,by-package,package,view}, the tarball at /patch/npm/minimist/1.2.8/<tok>/<uuid>/minimist-1.2.8.tgz, and the same path under /artifactory/socket-patch on the mirror port. Any mock that grants one npm patch will do.

unset BUN_OPTIONS
export SOCKET_PATCH_SERVER_URL=http://127.0.0.1:18080 SOCKET_PROXY_URL=http://127.0.0.1:18080
MB=http://127.0.0.1:18081/artifactory/socket-patch
sp() { socket-patch "$@" --api-url http://127.0.0.1:18080 --org o --api-token fake; }
mkdir p && cd p && git init -q && echo node_modules/ > .gitignore
echo '{"name":"app","version":"1.0.0","dependencies":{"minimist":"1.2.8"}}' > package.json
printf '[install]\nsaveTextLockfile = false\n' > bunfig.toml   # = true for the bun.lock variant
bun install && git add -A && git commit -qm init
sp scan --mode hosted --yes            # pins minimist on the patch server (:18080)
git commit -qam hosted
sp scan --mode hosted --yes --patch-mirror-url "$MB"; echo "exit=$?"
strings bun.lockb | grep -o 'http://127[^ ]*tgz'   # still :18080
rm -rf node_modules && BUN_INSTALL_CACHE_DIR=$(mktemp -d) bun install --frozen-lockfile
# the mock's log shows: GET :18080/patch/npm/minimist/... (the patch server, not the mirror)

Actual output (bun.lockb, Bun 1.4.5):

Switched 0 packages to hosted patches; rewrote 0 files.
No patches could be switched to hosted:
  pkg:npm/minimist@1.2.8: no lockfile entry pinning it could be rewritten (see the warning below)
Warning: bun.lockb package #1 installs minimist@1.2.8 from a URL or local tarball, not the registry, and CANNOT be redirected — bun installs it from that resolution, so that copy stays UNPATCHED; depend on the registry release to patch it

1 vulnerability left to patch: 1 is in packages this run did not patch.
exit=0

--json: events: [{"action":"skipped","errorCode":"redirect_unconfirmed"}], warnings: ["redirect_bun_non_registry_entry_skipped"].

Expected

CLI_CONTRACT.md, "Patch mirror (experimental)", A project already pinned on the patch server: "The yarn berry, Bun, Bundler, Poetry and PDM rewriters … leave a direct pin as it is: the patch is skipped (redirect_unconfirmed) and a redirect_mirror_pin_not_moved warning names the file, the host and the remedy". That should hold for bun.lockb as well as bun.lock. The remedy given for bun.lockb also has to be one that works there: rollback refuses a bun.lockb hosted pin (hosted_restore_refused, "restore it from version control instead (git checkout -- bun.lockb), then run bun install --force"), so "run socket-patch rollback <purl> and then this command again" stops at the first step.

redirect_bun_non_registry_entry_skipped is documented (the contract's warning table) for a user URL / file: tarball. A hosted pin in the patch server's shape, on the patch server or a configured patch host, shouldn't produce it or count as an unpatched copy.

Where it reproduces

Bun Lock redirect_mirror_pin_not_moved false redirect_bun_non_registry_entry_skipped
1.1.39 bun.lockb (v2) missing yes
1.2.23 bun.lock v1 present yes
1.2.23 bun.lockb missing yes
1.4.4 bun.lock v2 / bun.lockb present / missing yes / yes
1.4.5 bun.lock v2 / bun.lockb present / missing yes / yes

Main cfc870f, Linux. v5.1.0 has no patch mirror. A fresh project with no earlier pin passes: the pin goes onto the mirror, the frozen install fetches from the mirror, vex attests it, and rollback on bun.lock is byte-exact. The same holds for bun.lockb apart from rollback, which refuses bun.lockb by design. The defect isn't OS-specific.

Suspect code

  • crates/socket-patch-cli/src/commands/scan/hosted.rs:129 (mirror_pins_not_moved) looks for the earlier pin with vex::discover::hosted_host_in_text over the project's text files, so it never sees a pin inside binary bun.lockb.
  • crates/socket-patch-core/src/patch/redirect/mod.rs:6618 (text lock) and crates/socket-patch-core/src/patch/redirect/bun_binary.rs:70 (bun.lockb): is_prior_hosted_bun_spec only accepts an earlier pin on the new artifact URL's origin (the mirror), so a patch-server pin falls through to the #497 user-tarball branch. That branch emits the UNPATCHED warning and inserts into bundled_skipped_uuids.

Generated by Claude Code

Activity

  1. added
    bug
    bughunt
    on Nov 26, 2026
  2. added a commit that references this issue on Nov 26, 2026
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

    bugbughuntpm:bun

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions