Skip to content

fix: sameRange panics on a specifier that cannot take its semver group range, and launcher exits 0 on crash - #347

Open
lavaude wants to merge 2 commits into
JamieMason:mainfrom
lavaude:fix/same-range-panic-and-signal-exit
Open

lavaude wants to merge 2 commits into
JamieMason:mainfrom
lavaude:fix/same-range-panic-and-signal-exit

Conversation

@lavaude

@lavaude lavaude commented Oct 29, 2026

Copy link
Copy Markdown

Description (What)

  • same_range.rs: when an instance mismatches its semver group but get_specifier_with_preferred_semver_range() returns None, leave it as-is (valid) instead of calling .unwrap(). This is how the semverRange policy already handles the same case.
  • npm/index.cjs: exit with status ?? 1 instead of status || 0, so a binary killed by a signal fails instead of exiting 0.
  • Adds a regression test for the first change.

Justification (Why)

Fixes #345.

A specifier such as * (or a || union) has no version to apply a range prefix to, so with_range() returns None. In a sameRange group with a semver group, that reached .unwrap() and aborted the process:

thread 'main' panicked at src/version_group/same_range.rs:49:71:
called `Option::unwrap()` on a `None` value

The abort is a SIGABRT (exit 134 when run directly). spawnSync() reports status: null for a signal, so || 0 turned the crash into a successful exit. syncpack lint therefore passed in CI without having checked anything. The launcher change makes any future crash fail the build, not only this one.

Alternative considered: mark such instances unfixable (as #345 suggests). I followed semver_range_only.rs and left the specifier alone, but that is easy to switch if you prefer reporting it.

How Can This Be Tested?

  • cargo test same_range - the new test instance_whose_specifier_cannot_take_its_semver_group_range_is_left_as_is fails on main with the panic above and passes with this change.
  • cargo test passes in full, and cargo clippy --all-targets is clean.
  • Launcher: node -e "const {spawnSync}=require('child_process');const r=spawnSync('sh',['-c','kill -ABRT $$']);console.log(r.status||0, r.status??1)" prints 0 1.

…ver group range

A specifier such as '*' has no version to apply a range prefix to, so get_specifier_with_preferred_semver_range() returns None. same_range.rs unwrapped it, which aborted the process. Leave such an instance as-is, as the semverRange policy already does.

Signed-off-by: Edouard Lavaud <78795468+lavaude@users.noreply.github.com>
spawnSync() reports status null when the child is killed by a signal, so 'status || 0' turned a crash into a successful exit and CI checks passed without having run.

Signed-off-by: Edouard Lavaud <78795468+lavaude@users.noreply.github.com>
@JamieMason

Copy link
Copy Markdown
Owner

Thanks a lot for this @lavaude, I think I have a fix for this waiting on the dev branch but I will check and make sure 👍

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: sameRange group panics when a peer range cannot take its semver group prefix, and exits 0

2 participants