[BUG] npm pkg delete removes the first array item for a nonexistent property
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 83/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
- 領域
- cli
調査の方向性
issue では lib/utils/queryable.js、特に197–204行目の削除処理が示されています。そのコードを読み、親が配列の場合に Queryable.delete() が文字列キーをどのように処理するかを追い、報告された keywords[1] の挙動と比較してください。存在しない配列プロパティを削除しても配列が変更されないか、保存せずにパスを拒否し、有効なインデックスの削除は引き続き機能すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
npm pkg delete keywords.missing removes the first keyword.. even though there is no missing property. the command exits 0 without a warning.
with "keywords": ["alpha", "beta"], the result is "keywords": ["beta"].
keywords.beta does the same thing.. it removes "alpha", not the value named "beta". contributors.missing also removes the first contributor when contributors is an array of objects.
expected behavior
a nonexistent property should not cause an unrelated array item to be deleted.. either leave the array unchanged or reject the path without saving changes.
steps to reproduce
mkdir npm-pkg-delete-repro
cd npm-pkg-delete-repro
echo '{"name":"pkg-delete-repro","version":"1.0.0","keywords":["alpha","beta"]}' > package.json
npm pkg delete keywords.missing
cat package.json
result:
{
"name": "pkg-delete-repro",
"version": "1.0.0",
"keywords": [
"beta"
]
}
resetting the fixture and running npm pkg delete 'keywords[1]' correctly removes "beta". deleting a missing property from an object.. such as scripts.missing.. leaves its existing properties alone.
in lib/utils/queryable.js, the delete path calls _data.splice(_key, 1) whenever the parent is an array. a nonnumeric key remains a string.. splice() coerces it to NaN and treats that as index 0.
environment
- npm: 12.2.0, the current
latestregistry tag - Node.js: v24.21.0
- macOS 26.4, arm64
- reproduced with empty user and global npm config files
also reproduced with npm 11.19.0. the current latest branch's Queryable.delete() reproduces it directly too.. checked at ae98c62586b6fea44114f72e249e246a2981de70.
- 主要言語
- JavaScript
- スター
- 10.2k
- フォーク
- 4.9k
- 平均マージ
- 5日 4時間
- マージ済み PR(30日)
- 17
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
npm/cli のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 2 日以内に返信
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings logged対応中かも @lazerg が 25 日前に担当しました。 オープンEngineering Priority 1
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 2 日以内に返信
-
Engineering Priority 2
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 2 日以内に返信
-
`npm audit signatures` does not report how many packages it skipped for want of registry keys対応中かも @greenlincoln05 が 22 日前に担当しました。 オープンPriority 3
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
-
[BUG] E401 error message does not use the configured registry対応中かも @toufiq-dev が 25 日前に担当しました。 オープンBug Priority 3
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
HarperFast/harper#3299 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
osmlab/name-suggestion-index#12992 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
open-government-design-system/ogds-elements#199 ·
メンテナーはふだん 1 日以内に返信
-
area:plugin type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Document annotations cannot anchor visible code after a shorter or different fenced-code markerオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
paperclipai/paperclip#16898 ·
メンテナーはふだん 1 日以内に返信