[BUG] minVersion returns 0.0.0 when a 0.0.0 prerelease is the true minimum
メンテナーはふだん 4 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
- 領域
- backend
調査の方向性
issueで指定されているranges/min-version.jsのショートカットから始め、関連するminVersionのテストと、プレリリースバージョンが0.0.0とどのように比較されるかを調べます。issueの例を再現し、includePrereleaseを指定した場合に>=0.0.0-alpha <1.0.0と*の最小バージョンが正しく返されることを確認します。これらのケースが、文書化されている最小バージョンの動作を変更せずに通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
This is admittedly a bit pedantic, but minVersion seems to treat 0.0.0 as a special case. A prerelease lower bound is respected on every tuple except 0.0.0:
semver.minVersion('>=1.0.0-alpha <2.0.0').version // '1.0.0-alpha'
semver.minVersion('>=0.0.1-alpha <1.0.0').version // '0.0.1-alpha'
semver.minVersion('>=0.0.0-alpha <1.0.0').version // '0.0.0'
The same thing happens with includePrerelease, where 0.0.0-0 satisfies * but 0.0.0 is returned:
semver.minVersion('*', { includePrerelease: true }).version // '0.0.0'
This comes from the shortcut at the top of ranges/min-version.js, which tries 0.0.0 before 0.0.0-0 and returns the first one that matches.
Expected Behavior
I'd expect '0.0.0-alpha' and '0.0.0-0' respectively, since the README describes minVersion as returning "the lowest version that can match the given range", and the rest of the library agrees that these sort below 0.0.0 (lt, sort, minSatisfying).
I couldn't find anything (docs, tests, or the original PR npm/node-semver#241) suggesting 0.0.0 is meant to be special here, so I suspect the shortcut just wasn't written with prerelease lower bounds in mind. But if this is intentional it might be worth documenting.
Steps To Reproduce
npm install [email protected]- Run
node -e "console.log(require('semver').minVersion('>=0.0.0-alpha <1.0.0').version)" - See
0.0.0
Environment
- npm: 11.20.0
- Node: 26.12.1
- OS: macOS 26.6.1
- platform: Apple Silicon (arm64)
- semver: 7.8.5 (same code on
main)
AI disclosure: this issue was discovered with AI assistance
- 主要言語
- JavaScript
- スター
- 5.5k
- フォーク
- 622
- 平均マージ
- 4日 23時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
npm/node-semver のほかの issue
-
[BUG] new Range(comparator).test() throws TypeError for a prerelease version対応中かも @Boulea7 が 31 日前に担当しました。 オープンBug Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
npm/node-semver#908 ·
メンテナーはふだん 4 日以内に返信
-
semver:major
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
npm/node-semver#108 · コメント 6 件 ·
メンテナーはふだん 4 日以内に返信
-
[BUG] intersects() still returns true for an empty range against "*" (follow-up to #521)対応中かも @json-open-source が 30 日前に担当しました。 オープンBug Needs Triage
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
npm/node-semver#909 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
[BUG] `* || 1.2.3-alpha` won't match `1.2.3-alpha` (when includePrerelease = false)対応中かも @x0Lazarus が 36 日前に担当しました。 オープンBug Needs Triage
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
npm/node-semver#906 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
[BUG] gtr and ltr are wrong when a range has two bounds on the same side対応中かも @Prafyl が 41 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
npm/node-semver#904 ·
メンテナーはふだん 4 日以内に返信
npm/node-semver の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
hexlet-codebattle/codebattle#2374 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
security
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Waschndolos/open-clubmanager#185 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信