[BUG] gtr and ltr are wrong when a range has two bounds on the same side
I maintainer di solito rispondono entro 4 giorni
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
- Ambito
- tooling
Direzione di ricerca
Start in ranges/outside.js and reproduce the gtr/ltr examples from the issue with semver 7.8.5. Trace how comparator bounds are selected for ranges with multiple bounds on one side, then verify that gtr and ltr only return true when the version is beyond the complete range, including the README hole example.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
gtr and ltr give the wrong answer when a comparator set has more than one bound on the same side, and a lot of the time they both return true for the same version and range.
semver.gtr('1.5.0', '>1.0.0 >=2.0.0 <3.0.0') // true, but 1.5.0 is below the range
semver.ltr('1.5.0', '>1.0.0 >=2.0.0 <3.0.0') // true
semver.gtr('1.5.0', '>=2.0.0 <3.0.0') // false
The README example about the hole in 1.2 <1.2.9 || >2.0.0 hits it too, it says 1.2.10 is not less than that range but semver.ltr('1.2.10', '1.2 <1.2.9 || >2.0.0') returns true. 1.2 expands to >=1.2.0 <1.3.0-0 so that set ends up with two upper bounds.
Expected Behavior
gtr should only be true if the version is greater than every version in the range, and ltr the same the other way, so they shouldnt both be true.
Steps To Reproduce
Run the snippet above. The cause is in ranges/outside.js, it takes the comparators with the highest and lowest versions as the edges of the set, which only works when there is one bound on each side. With >1.0.0 >=2.0.0 <3.0.0 it uses >1.0.0 as the lower edge, so 1.5.0 isnt below it, and since it doesnt satisfy the range it gets counted as above it. i checked gtr/ltr against a brute force answer on about 97k random version/range pairs and 7.8.5 was wrong on around 13% of them.
Environment
- semver: 7.8.5 (same on main)
- Node: 22.17.1
- OS: Windows 11
- Lingua principale
- JavaScript
- Stelle
- 5.5k
- Fork
- 617
- Merge medio
- 4g 23h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di npm/node-semver
-
[BUG] new Range(comparator).test() throws TypeError for a prerelease versionForse già presa @00200200 l’ha presa 26 giorni fa. ApertaBug Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
npm/node-semver#908 ·
I maintainer di solito rispondono entro 4 giorni
-
semver:major
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
npm/node-semver#108 · 6 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
[BUG] intersects() still returns true for an empty range against "*" (follow-up to #521)Forse già presa @json-open-source l’ha presa 23 giorni fa. ApertaBug Needs Triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
npm/node-semver#909 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
[BUG] `* || 1.2.3-alpha` won't match `1.2.3-alpha` (when includePrerelease = false)Forse già presa @x0Lazarus l’ha presa 29 giorni fa. ApertaBug Needs Triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
npm/node-semver#906 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
npm/node-semver#900 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di npm/node-semver
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Add: Story4 CZApertacheck:passed logos:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
adobe/helix-shared#1310 ·
I maintainer di solito rispondono entro 1 giorno
-
[workshop-sim] Improve: Strengthen practice and checkpoints in Step 05 (What Are Agentic Workflows?)Apertafeedback simulation workshop
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
githubnext/gh-aw-workshop#4972 ·
I maintainer di solito rispondono entro 1 giorno
-
agent/ci-maintainer ci good first issue help wanted stage/010-actionable
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
cncf/endusers#1890 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno