ITADN

CLI crash when parsing malformed virtual package version

#2326Closedmaniktyagi04 创建于 2026-04-09
M
maniktyagi04commented
### Description The `create` CLI command throws a panic when users specify a malformed virtual package version argument. In `crates/rattler-bin/src/commands/create.rs` (around line 258), the CLI command detects virtual packages supplied by the `--virtual-package` command line option. If a virtual package has an invalid version string, the application panics due to the use of `.expect("Could not parse virtual package version")` rather than bubbling up a handled error. Since the CLI `create` module uses `miette::Result<()>`, this causes an abrupt unhandled crash rather than graceful error handling or usage tips. ### Steps to Reproduce ### Steps to Reproduce 1. Attempt to create an environment and pass a virtual package with a malformed version string that `Version::from_str` cannot parse. 2. Run the following command: ```bash rattler create -p ./env --virtual-package "my_pkg=invalid_version" some-pkg 3. Observe the runtime panic throwing "Could not parse virtual package version". ### Expected Behavior The CLI should fail gracefully and emit an intuitive `miette` diagnostic error (e.g., "invalid virtual package version"). It should immediately exit nicely with an appropriate status code without throwing a Rust stack trace or panic message. ### Actual Behavior The program panics and crashes via an `expect` unwrap failure.
关闭于 2026-04-09 0 条评论