Skip to content

feat(backend): improve http error when platform url missing; list available platforms#6200

Merged
jdx merged 1 commit intomainfrom
feat/http-better-platform-error
Sep 5, 2025
Merged

feat(backend): improve http error when platform url missing; list available platforms#6200
jdx merged 1 commit intomainfrom
feat/http-better-platform-error

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Sep 5, 2025

  • Improve error when no 'url' and no matching platform URL
  • Show available platforms detected from options
  • Helper moved to backend/static_helpers.rs and reused

This enhances UX by pointing users to valid platform keys when the current platform is unsupported.

Copilot AI review requested due to automatic review settings September 5, 2025 20:55
Copy link
Contributor

Copilot AI left a comment

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 improves the HTTP backend error handling by providing more helpful error messages when platform URLs are missing. It enhances user experience by listing available platforms when the current platform is unsupported, and consolidates shared OS/arch pattern logic into a reusable helper module.

  • Enhanced error message in HTTP backend to show available platforms when URL is missing
  • Added helper function to list available platforms with specific keys
  • Moved and shared OS/arch patterns to reduce code duplication

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/toolset/tool_version_options.rs Added iterator method for accessing tool version options
src/backend/static_helpers.rs Added shared OS/arch patterns and new function to list available platforms
src/backend/http.rs Enhanced error message to show available platforms when URL missing

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

Comment on lines +62 to +63
pub fn iter(&self) -> impl Iterator<Item = (&String, &String)> {
self.opts.iter()
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The iterator returns references to String rather than string slices. Consider returning impl Iterator<Item = (&str, &str)> for better ergonomics and to avoid unnecessary String allocations in consumer code.

Suggested change
pub fn iter(&self) -> impl Iterator<Item = (&String, &String)> {
self.opts.iter()
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)> {
self.opts.iter().map(|(k, v)| (k.as_str(), v.as_str()))

Copilot uses AI. Check for mistakes.
Comment on lines +126 to +129
/// Lists platform keys (e.g. "macos-x64") for which a given key_type exists (e.g. "url").
/// Supports both nested TOML (platforms.<os>-<arch>.<key_type>) and flat keys
/// (platforms_<os>_<arch>_<key_type>). Avoids parsing TOML inline; relies on
/// ToolVersionOptions nested key handling.
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

This function has extensive inline comments but lacks a proper docstring. Consider adding a doc comment that describes the function's purpose, parameters, return value, and provides examples of the platform key formats it supports.

Suggested change
/// Lists platform keys (e.g. "macos-x64") for which a given key_type exists (e.g. "url").
/// Supports both nested TOML (platforms.<os>-<arch>.<key_type>) and flat keys
/// (platforms_<os>_<arch>_<key_type>). Avoids parsing TOML inline; relies on
/// ToolVersionOptions nested key handling.
/// Returns a list of platform keys (e.g. `"macos-x64"`, `"linux-arm64"`) for which a given `key_type` (such as `"url"`) exists in the provided `ToolVersionOptions`.
///
/// This function supports both nested TOML keys and flat keys:
/// - **Nested format:** `platforms.<os>-<arch>.<key_type>` or `platform.<os>-<arch>.<key_type>`
/// - Example: `platforms.macos-x64.url`, `platform.linux-arm64.checksum`
/// - **Flat format:** `platforms_<os>_<arch>_<key_type>` or `platform_<os>_<arch>_<key_type>`
/// - Example: `platforms_macos_x64_url`, `platform_linux_arm64_checksum`
///
/// # Parameters
/// - `opts`: Reference to a `ToolVersionOptions` containing the key-value pairs to search.
/// - `key_type`: The type of value to look for (e.g., `"url"`, `"checksum"`).
///
/// # Returns
/// A vector of platform keys (in `<os>-<arch>` format) for which the specified `key_type` exists.
///
/// # Examples
/// Given the following keys in `opts`:
/// - `platforms.macos-x64.url`
/// - `platforms_linux_x64_url`
/// - `platform.windows-x64.checksum`
///
/// Calling `list_available_platforms_with_key(opts, "url")` will return:
/// - `"macos-x64"`
/// - `"linux-x64"`
///
/// Calling `list_available_platforms_with_key(opts, "checksum")` will return:
/// - `"windows-x64"`

Copilot uses AI. Check for mistakes.
@jdx jdx force-pushed the feat/http-better-platform-error branch from a192749 to 88213ff Compare September 5, 2025 21:03
@jdx jdx enabled auto-merge (squash) September 5, 2025 21:04
{
if let Some(platform_part) = rest.strip_suffix(&format!("_{}", key_type)) {
let platform_key = platform_part.replace('_', "-");
set.insert(platform_key);
Copy link

Choose a reason for hiding this comment

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

Bug: Key Parsing Error Causes Architecture Name Mismatch

The flat key parsing in list_available_platforms_with_key incorrectly converts all underscores to dashes when generating platform keys. This corrupts architecture names like x86_64 to x86-64, leading to mismatches with expected platform keys and incorrect suggestions.

Fix in Cursor Fix in Web

@jdx jdx merged commit 2188757 into main Sep 5, 2025
18 checks passed
@jdx jdx deleted the feat/http-better-platform-error branch September 5, 2025 21:13
@github-actions
Copy link

github-actions bot commented Sep 5, 2025

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.2 x -- echo 20.0 ± 1.6 18.0 28.1 1.04 ± 0.10
mise x -- echo 19.2 ± 1.0 18.0 25.2 1.00

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.2 env 18.1 ± 1.0 17.4 31.1 1.00
mise env 18.5 ± 7.3 17.4 176.8 1.02 ± 0.41

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.2 hook-env 17.5 ± 0.4 17.1 23.6 1.00 ± 0.03
mise hook-env 17.4 ± 0.2 17.0 18.8 1.00

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.2 ls 16.0 ± 0.5 15.4 22.5 1.00
mise ls 16.0 ± 0.4 15.5 21.1 1.00 ± 0.04

xtasks/test/perf

Command mise-2025.9.2 mise Variance
install (cached) 165ms ✅ 100ms +65%
ls (cached) 61ms 62ms -1%
bin-paths (cached) 65ms 66ms -1%
task-ls (cached) 477ms 481ms +0%

✅ Performance improvement: install cached is 65%

jdx pushed a commit that referenced this pull request Sep 6, 2025
### 🚀 Features

- **(backend)** improve http error when platform url missing; list
available platforms by @jdx in
[#6200](#6200)

### 🐛 Bug Fixes

- **(backend)** preserve arch underscores in platform keys by @jdx in
[#6202](#6202)
- **(task)** resolve hanging issue with multiple depends_post by @jdx in
[#6206](#6206)
- couldn't download node binary in Alpine, even if it exists in the
mirror url by @Hazer in [#5972](#5972)
- **breaking** use config_root for env._.path by @jdx in
[#6204](#6204)
- bugfix for paths that include spaces by @karim-elkholy in
[#6210](#6210)

### 📚 Documentation

- improve release notes generation by @jdx in
[#6197](#6197)
- fix release changelog contributor reporting by @jdx in
[#6201](#6201)

### Chore

- use fine-grained gh token by @jdx in
[#6208](#6208)
- use settings.local.json for claude config by @jdx in
[fd0fba9](fd0fba9)

### New Contributors

- @karim-elkholy made their first contribution in
[#6210](#6210)
- @Hazer made their first contribution in
[#5972](#5972)
@jdx jdx mentioned this pull request Sep 6, 2025
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Sep 8, 2025
## [2025.9.5](https://github.com/jdx/mise/compare/v2025.9.4..v2025.9.5) - 2025-09-06

### 🚀 Features

- **(task)** add timeout support for task execution by @jdx in [#6216](jdx/mise#6216)
- **(task)** sub-tasks in run lists by @jdx in [#6212](jdx/mise#6212)

### Chore

- fix npm publish action by @jdx in [14f4b09](jdx/mise@14f4b09)
- fix cloudflare release action by @jdx in [00afa25](jdx/mise@00afa25)
- fix git-cliff for release notes by @jdx in [15a9aed](jdx/mise@15a9aed)

## [2025.9.4](https://github.com/jdx/mise/compare/v2025.9.3..v2025.9.4) - 2025-09-06

### Chore

- fix git-cliff on release by @jdx in [3c388f2](jdx/mise@3c388f2)

## [2025.9.3](https://github.com/jdx/mise/compare/v2025.9.2..v2025.9.3) - 2025-09-06

### 🚀 Features

- **(backend)** improve http error when platform url missing; list available platforms by @jdx in [#6200](jdx/mise#6200)
- **(cli)** support scoped packages for all backend types by @earlgray283 in [#6213](jdx/mise#6213)
- **(http)** add URL replacement feature for HTTP requests by @ThomasSteinbach in [#6207](jdx/mise#6207)

### 🐛 Bug Fixes

- **(backend)** preserve arch underscores in platform keys by @jdx in [#6202](jdx/mise#6202)
- **(task)** resolve hanging issue with multiple depends_post by @jdx in [#6206](jdx/mise#6206)
- couldn't download node binary in Alpine, even if it exists in the mirror url by @Hazer in [#5972](jdx/mise#5972)
- **breaking** use config_root for env._.path by @jdx in [#6204](jdx/mise#6204)
- bugfix for paths that include spaces by @karim-elkholy in [#6210](jdx/mise#6210)

### 📚 Documentation

- improve release notes generation by @jdx in [#6197](jdx/mise#6197)
- fix release changelog contributor reporting by @jdx in [#6201](jdx/mise#6201)

### Chore

- use fine-grained gh token by @jdx in [#6208](jdx/mise#6208)
- use settings.local.json for claude config by @jdx in [fd0fba9](jdx/mise@fd0fba9)

### New Contributors

- @ThomasSteinbach made their first contribution in [#6207](jdx/mise#6207)
- @earlgray283 made their first contribution in [#6213](jdx/mise#6213)
- @karim-elkholy made their first contribution in [#6210](jdx/mise#6210)
- @Hazer made their first contribution in [#5972](jdx/mise#5972)

## [2025.9.2](https://github.com/jdx/mise/compare/v2025.9.1..v2025.9.2) - 2025-09-05

### 🐛 Bug Fixes

- **(ci)** set required environment variables for npm publishing by @jdx in [#6189](jdx/mise#6189)
- **(release)** clean up extra newlines in release notes formatting by @jdx in [#6190](jdx/mise#6190)
- **(release)** add proper newline after New Contributors section in cliff template by @jdx in [#6194](jdx/mise#6194)
- **(release)** fix changelog formatting to remove extra blank lines by @jdx in [#6195](jdx/mise#6195)
- **(release)** restore proper newline after New Contributors section by @jdx in [#6196](jdx/mise#6196)

### 🚜 Refactor

- **(ci)** split release workflow into separate specialized workflows by @jdx in [#6193](jdx/mise#6193)

### Chore

- **(release)** require GitHub Actions environment for release-plz script by @jdx in [#6191](jdx/mise#6191)

## [2025.9.1](https://github.com/jdx/mise/compare/v2025.9.0..v2025.9.1) - 2025-09-05

### 🐛 Bug Fixes

- python nested venv path order by @elvismacak in [#6124](jdx/mise#6124)
- resolve immutable release workflow and VERSION file timing issues by @jdx in [#6187](jdx/mise#6187)

### New Contributors

- @elvismacak made their first contribution in [#6124](jdx/mise#6124)

## [2025.9.0](https://github.com/jdx/mise/compare/v2025.8.21..v2025.9.0) - 2025-09-05

### 🚀 Features

- allow set/unset backend aliases by @roele in [#6172](jdx/mise#6172)

### 🐛 Bug Fixes

- **(aqua)** respect order of asset_strs by @risu729 in [#6143](jdx/mise#6143)
- **(java)** treat freebsd as linux (assuming linux compatability) by @roele in [#6161](jdx/mise#6161)
- **(nushell/windows)** Fix $env.PATH getting converted to a string by @zackyancey in [#6157](jdx/mise#6157)
- **(sync)** create uv_versions_path dir if it doesn't exist by @risu729 in [#6142](jdx/mise#6142)
- **(ubi)** show relevent error messages for v-prefixed tags by @risu729 in [#6183](jdx/mise#6183)
- remove nodejs/golang alias migrate code by @risu729 in [#6141](jdx/mise#6141)
- mise activate not working on powershell v5 by @L0RD-ZER0 in [#6168](jdx/mise#6168)

### 📚 Documentation

- **(task)** remove word "additional" to avoid confusions by @risu729 in [#6159](jdx/mise#6159)

### Chore

- update Cargo.lock by @risu729 in [#6184](jdx/mise#6184)

### New Contributors

- @zackyancey made their first contribution in [#6157](jdx/mise#6157)
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