Skip to content

fix(aqua): prevent double .exe extension when Windows override URL already ends in .exe#8863

Merged
jdx merged 4 commits intojdx:mainfrom
yusei-wy:fix/aqua-double-exe-extension
Apr 5, 2026
Merged

fix(aqua): prevent double .exe extension when Windows override URL already ends in .exe#8863
jdx merged 4 commits intojdx:mainfrom
yusei-wy:fix/aqua-double-exe-extension

Conversation

@yusei-wy
Copy link
Copy Markdown
Contributor

@yusei-wy yusei-wy commented Apr 3, 2026

Related: #8864

Summary

  • When a package's Windows override URL already includes .exe (e.g., GoogleCloudPlatform/cloud-sql-proxy), the complete_windows_ext logic appended another .exe, producing URLs like tool.exe.exe
  • Extracted a complete_windows_ext_to_asset() helper method that mirrors upstream aqua's completeWindowsExtToAsset decision tree, consolidating duplicated logic from url() and asset_strs() into a single place
  • Fixed url() to apply .exe after template expansion (matching upstream behavior)
  • Added unit tests to verify no double .exe and that .exe is still appended when missing

Changes

  • New: complete_windows_ext_to_asset() helper — guards against double .exe, checks complete_windows_ext flag and format == "raw"
  • Refactored: asset_strs() — replaced 2 duplicated if/else blocks with helper calls
  • Refactored: url() — simplified to parse_aqua_str then helper call (template expansion before .exe append, matching upstream)

Affected packages

37 packages in the aqua registry are affected, including cli/cli, kubernetes/kubernetes/kubectl, gruntwork-io/terragrunt, open-policy-agent/opa, rust-lang/rustup, etc.

Test plan

  • cargo test -p aqua-registry — all 44 tests pass (3 new tests added)
  • Verify with mise lock on a project using aqua:GoogleCloudPlatform/cloud-sql-proxy on Windows

🤖 Generated with Claude Code

…ready ends in .exe

When a package's Windows override URL already includes .exe (e.g.,
cloud-sql-proxy), the complete_windows_ext logic would append another
.exe, producing URLs like "tool.exe.exe". Add a check to skip appending
.exe when the URL or asset string already ends with it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 3, 2026

Greptile Summary

This PR fixes a bug in the aqua backend where calling complete_windows_ext on a package whose Windows override URL already ends in .exe (e.g. cloud-sql-proxy) would produce a double .exe.exe suffix. The fix extracts the logic into a shared complete_windows_ext_to_asset helper that guards with s.ends_with(".exe") before appending, and also corrects url() to parse the template string before checking the extension (rather than appending .exe to the raw template). Three unit tests covering the no-double-extension and the append-when-missing cases are included.

Confidence Score: 5/5

Safe to merge — targeted, well-tested bug fix with no logic regressions

All findings are P2 or lower; the fix correctly prevents double .exe, the refactoring is semantically equivalent for existing non-.exe templates, and new tests verify both the fixed case and the positive case.

No files require special attention

Important Files Changed

Filename Overview
crates/aqua-registry/src/types.rs Adds complete_windows_ext_to_asset helper guarding against double .exe; refactors url() to parse template before extension check; 3 targeted unit tests added

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[url() / asset_strs() called] --> B[parse_aqua_str — template substitution]
    B --> C[complete_windows_ext_to_asset]
    C --> D{os == 'windows'?}
    D -- No --> E[return as-is]
    D -- Yes --> F{s.ends_with('.exe')?}
    F -- Yes --> G[return as-is — no double .exe]
    F -- No --> H{complete_windows_ext && format == 'raw'?}
    H -- Yes --> I[append .exe]
    H -- No --> E
Loading

Reviews (4): Last reviewed commit: "[autofix.ci] apply automated fixes" | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the AquaPackage implementation in crates/aqua-registry/src/types.rs to prevent redundant .exe extensions when the complete_windows_ext flag is set for Windows packages in raw format. It adds checks to ensure the extension is only appended if it is not already present. Additionally, several unit tests were added to verify this behavior and ensure no regressions. I have no feedback to provide.

@jdx
Copy link
Copy Markdown
Owner

jdx commented Apr 4, 2026

The fix is correct — upstream aqua has the same guard. In pkg/config/windows_ext.go, the very first thing completeWindowsExtToAsset does is:

if strings.HasSuffix(asset, ".exe") {
    return asset
}

So the registry data is fine — mise was just missing this check that aqua has.

However, upstream's logic is more nuanced than just the .exe guard — it handles empty format with no file extension, and a configurable windows_ext field. I think this should be refactored to match upstream's completeWindowsExtToAsset decision tree rather than adding point fixes. The duplicated condition across url(), and both branches of asset_strs() should be extracted into a single helper method, mirroring how aqua centralizes this in one function.

This comment was generated by Claude Code.

@jdx jdx marked this pull request as draft April 4, 2026 15:35
yusei-wy and others added 2 commits April 5, 2026 10:45
Consolidate duplicated Windows .exe extension logic into a single helper
method, mirroring upstream aqua's completeWindowsExtToAsset decision tree.
Also fix url() to apply .exe after template expansion (matching upstream).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yusei-wy
Copy link
Copy Markdown
Contributor Author

yusei-wy commented Apr 5, 2026

Addressed the review feedback — refactored to extract a complete_windows_ext_to_asset() helper method that mirrors upstream aqua's completeWindowsExtToAsset decision tree.

Changes in the latest commit:

  • Consolidated the duplicated .exe logic from url() and both branches of asset_strs() into a single helper
  • Fixed url() to apply .exe after template expansion (matching upstream's order)
  • Net -13 lines (duplicated conditions removed)

This comment was generated by Claude Code.

@yusei-wy yusei-wy marked this pull request as ready for review April 5, 2026 01:55
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@jdx jdx merged commit 9a87762 into jdx:main Apr 5, 2026
35 checks passed
mise-en-dev added a commit that referenced this pull request Apr 6, 2026
### 🚀 Features

- **(config)** report env files in config ls and doctor output by
@SamSoldatenko in [#8853](#8853)
- add support for token sources in GitLab and Forgejo by @roele in
[#8868](#8868)

### 🐛 Bug Fixes

- **(aqua)** prevent double .exe extension when Windows override URL
already ends in .exe by @yusei-wy in
[#8863](#8863)
- **(bash)** avoid duplicate trust warning after cd by @timothysparg in
[#8920](#8920)
- **(env)** prevent config root injection into PATH via _.source by @jdx
in [#8936](#8936)
- **(install)** suppress spurious dependency warning when tool is
configured by @jdx in [#8923](#8923)

### 📚 Documentation

- **(node)** add section on pinning npm version by @jdx in
[#8925](#8925)
- add Windows default paths and mise.toml examples alongside CLI
commands by @jdx in [#8926](#8926)
- clarify common sources of confusion from GitHub discussions by @jdx in
[#8927](#8927)
- clarify Python venv mechanisms, JAVA_HOME behavior, and activation
performance by @jdx in [#8928](#8928)
- add FAQ and troubleshooting entries based on common Discord questions
by @jdx in [#8930](#8930)

### New Contributors

- @SamSoldatenko made their first contribution in
[#8853](#8853)
- @yusei-wy made their first contribution in
[#8863](#8863)
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