Skip to content

Conversation

@thejcannon
Copy link
Contributor

@thejcannon thejcannon commented Nov 12, 2025

(From discussion #6951)

Summary

This PR adds a format config to http backend, to help in corner-cases where the format isn't given (or is wrong).

Testing

Added a new E2E test (those are awesome!!)

Note: We could add more tests:

  • one for compressed binary without extensions format = "gz"
  • one for "completely wrong extension"
    if you wanna upload more binaries!

Note

Adds a format option (with platform-specific overrides) to force archive type detection when URLs lack or misstate extensions, with docs and e2e tests.

  • Backend:
    • Support explicit format (incl. platform-specific) in src/backend/http.rs by appending the given format to the downloaded file path for correct archive detection.
    • Adjust extraction logic to handle compressed binaries/raw files using the updated path/extension.
  • Docs:
    • Document format option and platform-specific formats in docs/dev-tools/backends/http.md.
  • Tests:
    • Add e2e/backend/test_http_format covering explicit format and per-platform format.

Written by Cursor Bugbot for commit 3c978d7. This will update automatically on new commits. Configure here.

@thejcannon thejcannon changed the title Add 'format' to http backend feat: Add 'format' to http backend Nov 12, 2025
@jdx jdx changed the title feat: Add 'format' to http backend feat(http): Add 'format' to http backend Nov 12, 2025
@jdx
Copy link
Owner

jdx commented Nov 12, 2025

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!


@jdx jdx marked this pull request as draft November 12, 2025 23:22
@thejcannon
Copy link
Contributor Author

Whoops, forgot I had some local changes, let me revert that 😅

@jdx jdx marked this pull request as ready for review November 13, 2025 17:00
Copilot AI review requested due to automatic review settings November 13, 2025 17:00
@jdx jdx enabled auto-merge (squash) November 13, 2025 17:00
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 adds a format configuration option to the HTTP backend, allowing users to explicitly specify archive formats when URLs lack proper file extensions or have incorrect ones.

Key Changes:

  • Added format configuration support with platform-specific overrides
  • Modified archive format detection to use the specified format when provided
  • Added documentation and E2E tests for the new feature

Reviewed Changes

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

File Description
src/backend/http.rs Implements format detection override by appending the specified format as an extension to the file path for proper archive type detection
e2e/backend/test_http_format Adds E2E tests covering both explicit format specification and platform-specific format configuration
docs/dev-tools/backends/http.md Documents the new format option with examples for both global and platform-specific usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +163 to +169
let current_ext = file_path.extension().and_then(|e| e.to_str()).unwrap_or("");
let new_ext = if current_ext.is_empty() {
added_extension.clone()
} else {
format!("{}.{}", current_ext, added_extension)
};
file_path.set_extension(new_ext);
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

The logic for combining extensions may produce incorrect results. If the file already has a valid extension like 'tar.gz' and the user specifies format='tar.gz', this would result in 'tar.gz.tar.gz'. Consider validating that the specified format isn't already present in the extension before appending it.

Suggested change
let current_ext = file_path.extension().and_then(|e| e.to_str()).unwrap_or("");
let new_ext = if current_ext.is_empty() {
added_extension.clone()
} else {
format!("{}.{}", current_ext, added_extension)
};
file_path.set_extension(new_ext);
let file_name = file_path.file_name().and_then(|n| n.to_str()).unwrap_or("");
// Only append the extension if it's not already present at the end of the file name
if !file_name.ends_with(&format!(".{}", added_extension)) {
let current_ext = file_path.extension().and_then(|e| e.to_str()).unwrap_or("");
let new_ext = if current_ext.is_empty() {
added_extension.clone()
} else {
format!("{}.{}", current_ext, added_extension)
};
file_path.set_extension(new_ext);
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was arguably intentional for simplicity sake. Trying to "maybe replace" the extension is error-prone (since files like foo-1.0.0 have the extension .0)

@jdx jdx merged commit d08a1dc into jdx:main Nov 13, 2025
29 checks passed
@thejcannon thejcannon deleted the jcannon/http-format branch November 13, 2025 17:03
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Format Omission Corrupts Cache Integrity

The cache key generation doesn't include the format option, which can cause cache collisions when the same file is used with different format specifications. If two tools use identical files but specify different format values (like tar.gz vs zip vs no format), they'll share the same cache entry even though they require different extraction methods, resulting in incorrect installations.

src/backend/http.rs#L43-L60

mise/src/backend/http.rs

Lines 43 to 60 in 3c978d7

/// Generate a cache key based on the actual file content (checksum) and extraction options
fn get_file_based_cache_key(
&self,
file_path: &Path,
opts: &ToolVersionOptions,
) -> Result<String> {
let checksum = hash::file_hash_blake3(file_path, None)?;
// Include extraction options in cache key to handle different extraction needs
let mut cache_key_parts = vec![checksum.clone()];
if let Some(strip_components) = opts.get("strip_components") {
cache_key_parts.push(format!("strip_{strip_components}"));
}
let cache_key = cache_key_parts.join("_");
debug!("Using file-based checksum as cache key: {}", cache_key);
Ok(cache_key)

Fix in Cursor Fix in Web


jdx pushed a commit that referenced this pull request Nov 15, 2025
### 🚀 Features

- **(http)** Add 'format' to http backend by @thejcannon in
[#6957](#6957)

### 🐛 Bug Fixes

- **(bootstrap)** wrong directory on first run by @vmeurisse in
[#6971](#6971)
- **(tasks)** fix nested colons with `mise task edit` by @jdx in
[#6978](#6978)
- Use compatible env flags by @thejcannon in
[#6964](#6964)
- Flush vfox download buffer by @blampe in
[#6969](#6969)

### 📚 Documentation

- `arch()` template is `x64` by @thejcannon in
[#6967](#6967)
- update section headers in getting-started.md by @JunichiroKohari in
[#6980](#6980)

### New Contributors

- @JunichiroKohari made their first contribution in
[#6980](#6980)
- @blampe made their first contribution in
[#6969](#6969)
- @thejcannon made their first contribution in
[#6964](#6964)

## 📦 Aqua Registry Updates

#### New Packages (1)

- [`cirruslabs/cirrus-cli`](https://github.com/cirruslabs/cirrus-cli)

#### Updated Packages (1)

- [`axodotdev/cargo-dist`](https://github.com/axodotdev/cargo-dist)
@thejcannon
Copy link
Contributor Author

@jdx what do you think of that Cursor Bugbot comment? I actually think it may have legs...

@jdx
Copy link
Owner

jdx commented Nov 18, 2025

it might, I'm not sure

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