Skip to content

fix: duplicate versions and validation in mise tool#6001

Merged
jdx merged 2 commits into
mainfrom
fix/tool-command-duplicates-and-validation
Aug 13, 2025
Merged

fix: duplicate versions and validation in mise tool#6001
jdx merged 2 commits into
mainfrom
fix/tool-command-duplicates-and-validation

Conversation

@jdx

@jdx jdx commented Aug 12, 2025

Copy link
Copy Markdown
Owner

Summary

  • Fixed duplicate version display in mise tool command when a tool version is both current and installed
  • Added proper error handling for invalid tool names
  • Created comprehensive e2e tests

Problem

  1. mise tool opentofu was showing the same version twice in installed versions (e.g., "1.10.2 1.10.2")
  2. mise tool INVALID wasn't returning an error when given an invalid tool name

Solution

  1. Fixed duplicate versions: The root cause was in src/toolset/mod.rs:list_installed_versions() where versions were being pushed to the result vector twice - once for current versions and then unconditionally. Added an else clause to only create and push new ToolVersion when it's not already a current version.

  2. Fixed error handling: Modified src/cli/tool.rs to properly validate that a backend exists and return an error for invalid tools that aren't configured.

  3. Added HashSet deduplication: As an extra safeguard, added HashSet-based deduplication in the tool command to ensure no duplicates are displayed.

Test plan

  • Created comprehensive e2e test (e2e/cli/test_tool) that verifies:
    • Invalid tool names properly error
    • Installed versions don't contain duplicates
  • Manually verified fixes work with mise tool opentofu and mise tool INVALID
  • All existing tests pass

🤖 Generated with Claude Code

- Fixed duplicate version display when a tool version is both current and installed
  The issue was in list_installed_versions() pushing versions twice
- Added proper error handling for invalid tool names
- Added HashSet deduplication as extra safeguard against duplicates
- Created comprehensive e2e tests for the tool command

Fixes reported issues:
- 'mise tool opentofu' showing same version twice in installed versions
- 'mise tool INVALID' not erroring out properly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 12, 2025 20:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes two issues in the mise tool command: duplicate version display and lack of error handling for invalid tool names. The changes ensure proper validation and deduplication of tool versions.

  • Fixed duplicate version display by adding proper conditional logic in version listing
  • Added validation to return errors for invalid/non-existent tool names
  • Created comprehensive end-to-end tests to verify the fixes

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/toolset/mod.rs Fixed duplicate version logic by adding else clause to prevent double-adding versions
src/cli/tool.rs Added backend validation and HashSet deduplication for installed versions
e2e/cli/test_tool Added comprehensive tests for invalid tools and duplicate version scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/toolset/mod.rs
.await?;
versions.push((b.clone(), tv));
}
}

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be a misplaced closing brace. This brace seems to close the outer loop prematurely, which would prevent processing of subsequent backends. The brace should likely be moved to after line 511 to properly close the inner loop iteration.

Copilot uses AI. Check for mistakes.
cursor[bot]

This comment was marked as outdated.

@github-actions

github-actions Bot commented Aug 12, 2025

Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.8.8 x -- echo 17.9 ± 0.2 17.5 21.3 1.00
mise x -- echo 18.0 ± 0.3 17.5 21.6 1.00 ± 0.02

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.8.8 env 17.4 ± 0.2 17.0 20.1 1.00
mise env 17.6 ± 0.6 16.9 24.6 1.01 ± 0.04

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.8.8 hook-env 17.0 ± 0.2 16.3 18.5 1.00
mise hook-env 17.1 ± 0.2 16.7 18.3 1.01 ± 0.02

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.8.8 ls 15.9 ± 0.2 15.3 17.0 1.03 ± 0.01
mise ls 15.5 ± 0.1 14.8 16.0 1.00

xtasks/test/perf

Command mise-2025.8.8 mise Variance
install (cached) 186ms ✅ 101ms +84%
ls (cached) 79ms ✅ 60ms +31%
bin-paths (cached) 63ms 64ms -1%
task-ls (cached) 474ms 463ms +2%

✅ Performance improvement: install cached is 84%
✅ Performance improvement: ls cached is 31%

@jdx jdx changed the title fix(cli): fix duplicate versions and validation in 'mise tool' command fix: fix duplicate versions and validation in 'mise tool' command Aug 13, 2025
@jdx jdx changed the title fix: fix duplicate versions and validation in 'mise tool' command fix: duplicate versions and validation in mise tool Aug 13, 2025
@jdx jdx merged commit a6e0e8f into main Aug 13, 2025
18 of 20 checks passed
@jdx jdx deleted the fix/tool-command-duplicates-and-validation branch August 13, 2025 01:49
jdx pushed a commit that referenced this pull request Aug 13, 2025
### 📦 Registry

- add vfox-yarn as primary yarn backend by
[@jdx](https://github.com/jdx) in
[#5982](#5982)
- add missing description field for a lot of tools by
[@jylenhof](https://github.com/jylenhof) in
[#5966](#5966)
- rename benthos to redpanda-connect by
[@risu729](https://github.com/risu729) in
[#5984](#5984)
- rename coq to rocq by [@risu729](https://github.com/risu729) in
[#5985](#5985)

### 🚀 Features

- **(timeout)** show duration, URL, and config hint on timeouts;
increase fetch timeout default to 10s by [@jdx](https://github.com/jdx)
in [#5991](#5991)

### 🐛 Bug Fixes

- **(aqua)** add executable permissions for zip-extracted binaries by
[@itochan](https://github.com/itochan) in
[#5998](#5998)
- **(core)** auto-repair corrupted pyenv cache by recloning on update
failure by [@jdx](https://github.com/jdx) in
[#6003](#6003)
- duplicate versions and validation in `mise tool` by
[@jdx](https://github.com/jdx) in
[#6001](#6001)

### 📚 Documentation

- **(tools)** document per-tool postinstall option in [tools] by
[@jdx](https://github.com/jdx) in
[#5993](#5993)
- Update install instructions for nushell by
[@Joniator](https://github.com/Joniator) in
[#5981](#5981)
- README.md typo by [@jdx](https://github.com/jdx) in
[#5990](#5990)

### ◀️ Revert

- Revert "docs: Update install instructions for nushell" by
[@jdx](https://github.com/jdx) in
[#5983](#5983)
- Revert "fix(aqua): add executable permissions for zip-extracted
binaries" by [@jdx](https://github.com/jdx) in
[#6004](#6004)

### 📦️ Dependency Updates

- update taiki-e/install-action digest to 2c73a74 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#5962](#5962)
- update docker/metadata-action digest to c1e5197 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#5961](#5961)
- update docker/login-action digest to 184bdaa by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#5958](#5958)

### Chore

- cargo up by [@jdx](https://github.com/jdx) in
[#5992](#5992)

### New Contributors

- @Joniator made their first contribution in
[#5981](#5981)
- @jylenhof made their first contribution in
[#5966](#5966)
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.

2 participants