[BUG] Workspace-scoped `overrides` are ignored for unlinked prerelease workspaces in `npm query` / `loadActual()`
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, nodejs
- Lĩnh vực
- tooling
Hướng nghiên cứu
Start in workspaces/arborist/lib/override-set.js: compare getEdgeRule (around line 92) with getNodeRule/getMatchingRule (lines 128-156), where unversioned keys should short-circuit like getEdgeRule does. Reproduce with the workspace layout in the issue, then run Arborist override/workspace tests covering loadActual() and npm query ":invalid". Done means the prerelease workspace ws-a gets the nested [email protected] override and npm query ":invalid" prints []; check linked PR #10357 before starting to avoid duplicate work.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
When a workspace has not been symlinked into root node_modules yet (for example after installing another workspace with npm install -w ws-b), Arborist#loadActual() loads that workspace target with useRootOverrides: true, which resolves its override set via root.overrides.getNodeRule({ name: pkg.name, version: pkg.version }).
If the root package.json scopes an override under that workspace's bare name (such as "overrides": { "ws-a": { "semver": "7.6.3" } }) and ws-a has a prerelease version ("version": "1.0.0-rc.1"), getNodeRule fails to match the ws-a rule and falls back to the root OverrideSet. As a result, ws-a's dependency edge keeps its raw spec (^6.0.0) instead of the overridden 7.6.3, and npm query ":invalid" falsely reports the hoisted [email protected] as invalid (relevant fields):
[
{
"pkgid": "[email protected]",
"from": [
"packages/ws-b",
"packages/ws-a"
]
}
]
With the exact same setup when packages/ws-a/package.json has "version": "1.0.0" (or after a full npm install creates the node_modules/ws-a symlink so overrides propagate via getEdgeRule), ws-a receives the override rule and npm query ":invalid" returns [].
Root cause: in workspaces/arborist/lib/override-set.js, OverrideSet#getNodeRule (and getMatchingRule) checks semver.satisfies(node.version, rule.keySpec) || semver.satisfies(node.version, rule.value) without short-circuiting if (rule.keySpec === '*') return rule the way getEdgeRule does on line 92, and semver.satisfies('1.0.0-rc.1', '*') evaluates to false.
Expected Behavior
Unversioned override keys (rule.keySpec === '*') match prerelease node versions in getNodeRule and getMatchingRule just as they do in getEdgeRule, so [email protected] receives its nested [email protected] override during loadActual() and npm query ":invalid" returns [].
Steps To Reproduce
WORK=$(mktemp -d)
cd "$WORK"
mkdir -p packages/ws-a packages/ws-b
cat > package.json << 'EOF'
{
"name": "repro",
"version": "1.0.0",
"workspaces": ["packages/*"],
"overrides": {
"ws-a": {
"semver": "7.6.3"
}
}
}
EOF
cat > packages/ws-a/package.json << 'EOF'
{
"name": "ws-a",
"version": "1.0.0-rc.1",
"dependencies": {
"semver": "^6.0.0"
}
}
EOF
cat > packages/ws-b/package.json << 'EOF'
{
"name": "ws-b",
"version": "1.0.0",
"dependencies": {
"semver": "7.6.3"
}
}
EOF
npm install -w ws-b --no-audit --no-fund
npm query ":invalid"
Changing "version": "1.0.0-rc.1" in packages/ws-a/package.json to "1.0.0" and re-running npm query ":invalid" prints [].
Environment
- npm: 12.2.3 (bundles
@npmcli/arborist10.0.5; also reproduces onnpm/clilatestat787f1520fa412e91a5792468f1c7f25b166867a6) - Node.js: v24.22.2
- OS Name: Debian GNU/Linux 12 (bookworm), Linux 6.1 x86_64
- npm config:
; defaults (empty .npmrc)
Credit: https://ucsbplse.github.io/
- Ngôn ngữ chính
- JavaScript
- Star
- 10.3k
- Fork
- 5k
- Merge trung bình
- 4 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 26
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của npm/cli
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endingsCó thể đã có người làm @saruk-vedant đã nhận 7 ngày trước. Đang mởBug Needs Triage Triage Requested
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyCó thể đã có người làm @drawliin đã nhận 42 ngày trước. Đang mởcmd:delete Priority 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 2 ngày
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởEngineering Priority 1
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 2 ngày
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysCó thể đã có người làm @greenlincoln05 đã nhận 63 ngày trước. Đang mởPriority 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
docs: add SECURITY.md vulnerability reporting policyCó thể đã có người làm @AK-Lmn đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
flisk-sh/linux2wasm#12 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
possible bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Mintplex-Labs/anything-llm#7388 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 60/100
Maintainer thường phản hồi trong vòng 1 ngày
-
v6: Minified bootstrap.min.css is missing header infoCó thể đã có người làm @lazerg đã nhận hôm nay. Đang mởbug build confirmed has-pr v6
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
githubnext/gh-aw-workshop#6332 ·
Maintainer thường phản hồi trong vòng 1 ngày