Repository navigation
Fix replace-registry-host ${VAR} warning (#1233) - #1404
Merged
Mikola Lysenko (mikolalysenko) merged 3 commits intoOct 12, 2026
Merged
Conversation
Assisted-by: Claude Code:claude-opus-5-5
npm runs every config value through env-replace, in every layer.
socket-patch read replace-registry-host, allow-remote and allow-file
raw, so replace-registry-host=${RRH} with RRH=always looked like the
literal "${RRH}". The hosted scan then gave no warning and reported
success while every npm ci failed with E404 (#1233). The same gap made
allow-remote=${AR} and allow-file=${AF} read as non-"all" values.
Values from the env, project, user, global and builtin layers are now
trimmed and env-replaced before they are compared, like npm's
parseField. An unset ${VAR} stays literal, as it does in npm.
Fixes #1233
Assisted-by: Claude Code:claude-opus-5-5
Review of the first commit: expanding allow-remote and allow-file
against the local environment could flip a committed `${VAR}` to "all"
on one machine and hide a refusal that a CI runner without the variable
still hits. For those two settings the raw `${VAR}` already reads as
"not all", which is the safe direction, so they go back to raw reads.
replace-registry-host stays expanded, because expanding it can only add
the warning. The warning now quotes the value as written and what npm
expands it to, so the user can find the line or variable it names.
config_path reuses the new config_value helper.
Refs #1233
Assisted-by: Claude Code:claude-opus-5-5
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 11, 2026 23:56
Collaborator
Author
|
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 9be0112. Configure here.
Wenxin Jiang (Wenxin-Jiang)
approved these changes
Oct 12, 2026
Collaborator
Author
|
Ready for review (burn-down agent)
Generated by Claude Code |
Mikola Lysenko (mikolalysenko)
deleted the
agent/fix-npmrc-env-replace-values
branch
October 12, 2026 02:57
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.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #1233
Summary
npm env-replaces every config value (
@npmcli/configparseField→envReplace) in every layer. Soreplace-registry-host=${RRH}withRRH=alwaysrewrites every hosted pin exactly like=always, and everynpm cithen fails E404. The hosted scan read the literal${RRH}, matched no host, gave no #812 warning and reported success.The effective
replace-registry-hostvalue is now trimmed and env-replaced the way npm does it, in the env, project, user, global and builtin layers. Theredirect_npm_replace_registry_hostwarning fires, and it quotes both the value as written and what npm expands it to, e.g.the project .npmrc sets `replace-registry-host=${RRH}` (npm expands it to `always`). An unset${RRH}stays literal, as it does in npm, and matches no host.Root cause
effective_replace_registry_hostandouter_file_valuepassednpmrc_top_level_value(...)through unchanged. Only path-typed settings were env-replaced (NpmConfigEnv::config_path).Change
NpmConfigEnv::config_valuetrims a value and env-replaces it, the wayparseFieldreads a string.config_pathnow reuses it.OuterAllowRemote::config_envkeeps the environment the layers were resolved with, so the project.npmrcvalue is expanded against the same environment.effective_replace_registry_hostreturnsEffectiveSetting { value, raw, source }. The engine matches onvalue, andnpm_replace_registry_host_detailshowsrawandvalue.replace-registry-hostsection documents the env-replace.Test evidence (red → green)
.npmrc=${RRH},RRH=alwaysvendor::redirect_npm_allow_remote::replace_registry_host_via_env_interpolation_is_warnedno redirect_npm_replace_registry_host).npmrc=${RRH},RRH=always${RRH?}, padded value, unset varnpmrc::tests::replace_registry_host_values_are_env_replaced_like_npmCommands run locally:
cargo fmt --all -- --check: cleancargo clippy --workspace --all-features -- -D warnings: cleancargo test -p socket-patch-core --all-features --lib: 6302 passed, 4 failed. The 4 are the root-in-sandbox permission tests that also fail onmainhere (relax_loop_must_not_traverse_symlinked_root,an_unremovable_hidden_lock_keeps_every_store_entry,wire_write_failure_maps_error_and_leaves_lock_untouched,wire_failure_rolls_back_already_written_files).cargo test -p socket-patch-cli --all-features --test vendor -- redirect_npm: 10 passedcargo test --workspaceran the sandbox out of disk while linking test binaries. CI runs the whole matrix and is green on 9be0112 (ci-oksuccess). Bugbot found no issues on 9be0112.No wrapper changes (
npm/,pypi/,gem/) are needed, because the wrappers only dispatch to the binary./code-review high
Fixed:
allow-remoteand the vendoredallow-file. Review pointed out that expanding a committed${VAR}against the local environment can turn it intoallon one machine and hide a refusal that a CI runner without the variable still hits. Read raw, a${VAR}already counts as "notall" for those settings, which is the safe direction, so they are back to raw reads.replace-registry-hoststays expanded, because expanding it can only add a warning.config_pathreusesconfig_value.Not changed:
${RRH}gives no warning, even though CI might set it. npm itself reads it literally in that environment, and guessing at other environments' variables would warn on every templated.npmrc.OuterAllowRemoteholds a copy of the env snapshot (config_env). The engine gets the outer layers only throughnpm_outerand has no other handle on the environment, so this is the smallest way to expand the project layer the same way..npmrcreads (lockfile-dir, pnpmmodules-dir, registry keys) are also env-replaced by the package managers.🤖 Generated with Claude Code
https://claude.ai/code/session_01TS3s2TugzYrj9UXe71AovS
Generated by Claude Code