-
-
Notifications
You must be signed in to change notification settings - Fork 669
fix(tool-stub): use URL hash as version for HTTP backend with "latest" #5828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When tool stubs use the HTTP backend with version "latest" (the default), generate a stable version string based on the URL hash. This prevents repeated installations of the same tool when the URL hasn't changed. The version format becomes "url-{8-char-hash}" instead of "latest", ensuring consistent caching behavior and avoiding reinstallation on every run. π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this 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 fix addresses an issue where HTTP-backed tool stubs with "latest" versions were being repeatedly installed due to unstable version strings. The change generates a stable version string based on the URL hash for HTTP backends using "latest" versions.
- Modifies the
to_tool_request
method to generate hash-based versions for HTTP backends - Adds URL hash generation logic to create stable version identifiers
- Imports the
lookup_platform_key
helper function for platform-specific URL lookups
|
||
ToolRequest::new_opts(backend_arg.into(), &self.version, options, source) | ||
// For HTTP backend with "latest" version, use URL hash as version for stability | ||
let version = if self.tool_name.starts_with("http:") && self.version == "latest" { |
Copilot
AI
Jul 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition only checks for 'http:' URLs but doesn't include 'https:' URLs. This will miss HTTPS-based tool stubs that should also benefit from stable versioning.
let version = if self.tool_name.starts_with("http:") && self.version == "latest" { | |
let version = if (self.tool_name.starts_with("http:") || self.tool_name.starts_with("https:")) && self.version == "latest" { |
Copilot uses AI. Check for mistakes.
lookup_platform_key(&options, "url").or_else(|| opts.get("url").cloned()) | ||
{ | ||
// Use first 8 chars of URL hash as version | ||
format!("url-{}", &hash::hash_to_str(&url)[..8]) |
Copilot
AI
Jul 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String slicing with [..8]
can panic if the hash string is shorter than 8 characters. Consider using get(..8).unwrap_or(&hash)
or ensure the hash function always returns sufficient characters.
format!("url-{}", &hash::hash_to_str(&url)[..8]) | |
{ | |
let hash = hash::hash_to_str(&url); | |
format!("url-{}", hash.get(..8).unwrap_or(&hash)) | |
} |
Copilot uses AI. Check for mistakes.
Hyperfine Performance
|
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
mise-2025.7.30 x -- echo |
18.1 Β± 0.5 | 17.7 | 26.2 | 1.00 |
mise x -- echo |
18.4 Β± 0.3 | 17.8 | 21.1 | 1.01 Β± 0.03 |
mise env
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
mise-2025.7.30 env |
17.6 Β± 0.4 | 17.0 | 22.7 | 1.00 |
mise env |
17.7 Β± 0.3 | 17.2 | 19.7 | 1.01 Β± 0.03 |
mise hook-env
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
mise-2025.7.30 hook-env |
17.3 Β± 0.2 | 16.8 | 18.6 | 1.00 |
mise hook-env |
17.5 Β± 0.4 | 17.0 | 21.0 | 1.01 Β± 0.03 |
mise ls
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
mise-2025.7.30 ls |
15.8 Β± 0.5 | 15.3 | 21.7 | 1.00 |
mise ls |
16.1 Β± 0.2 | 15.6 | 17.0 | 1.02 Β± 0.03 |
xtasks/test/perf
Command | mise-2025.7.30 | mise | Variance |
---|---|---|---|
install (cached) | 187ms | β 129ms | +44% |
ls (cached) | 80ms | 81ms | -1% |
bin-paths (cached) | 64ms | 65ms | -1% |
task-ls (cached) | 491ms | 493ms | +0% |
β Performance improvement: install cached is 44%
### π Features - **(tool-stubs)** append to existing tool-stub files instead of overwriting by [@jdx](https://github.com/jdx) in [#5835](#5835) - **(tool-stubs)** add auto-platform detection from URLs by [@jdx](https://github.com/jdx) in [#5836](#5836) - Add sops.strict setting for non-strict decryption mode by [@pepicrft](https://github.com/pepicrft) in [#5378](#5378) ### π Bug Fixes - **(tool-stub)** use URL hash as version for HTTP backend with "latest" by [@jdx](https://github.com/jdx) in [#5828](#5828) - **(tool-stubs)** fix -v and --help flags by [@jdx](https://github.com/jdx) in [#5829](#5829) - **(tool-stubs)** use 'checksum' field instead of 'blake3' in generated stubs by [@jdx](https://github.com/jdx) in [#5834](#5834) - dotnet SearchQueryService fallback by [@acesyde](https://github.com/acesyde) in [#5824](#5824) - registry.toml - Specify sbt dependency on java by [@jatcwang](https://github.com/jatcwang) in [#5827](#5827) ### π§ͺ Testing - remove has test which is failing by [@jdx](https://github.com/jdx) in [4aa9cc9](4aa9cc9) ### New Contributors - @jatcwang made their first contribution in [#5827](#5827)
When tool stubs use the HTTP backend with version "latest" (the default),
generate a stable version string based on the URL hash. This prevents
repeated installations of the same tool when the URL hasn't changed.
The version format becomes "url-{8-char-hash}" instead of "latest",
ensuring consistent caching behavior and avoiding reinstallation on
every run.
π€ Generated with Claude Code
Co-Authored-By: Claude [email protected]