fix(config): limit resolved backend opts to aliases#9315
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new end-to-end test to verify that tool installations using registry short names do not inherit configuration from entries keyed by full backend names. Feedback suggests enhancing the test's robustness by using the --force flag and adding a verification step to ensure the tool is correctly installed.
Greptile SummaryThis PR fixes a bug where Confidence Score: 5/5Safe to merge; the narrowed fallback is well-reasoned and all three behavioural cases are covered by e2e tests The core logic change is small and correct: or_else only fires when no direct short-name match exists, and has_tool_alias precisely distinguishes configured aliases from registry short-name resolution. No P1/P0 findings; all remaining observations are P2 or lower. No files require special attention Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["get_tool_opts(backend_arg)"] --> B["short_match = trs.find(short == ba.short)"]
B --> C{short_match found?}
C -- Yes --> G["Return short_match options\n(alias-specific wins)"]
C -- No --> D{"has_tool_alias(ba.short)?"}
D -- No\n(registry short name) --> H["Return None\n(no options leaked)"]
D -- Yes\n(configured alias or plugin URL) --> E["resolved_ba = BackendArg::new(ba.full())"]
E --> F["resolved_match = trs.find(short == resolved_ba.short)"]
F --> I["Return resolved_match options\n(compatibility fallback)"]
Reviews (7): Last reviewed commit: "Rename has_backend_alias to has_tool_ali..." | Re-trigger Greptile |
### 🚀 Features - **(registry)** add --security flag to include security info in JSON output by @jdx in [#9364](#9364) ### 🐛 Bug Fixes - **(config)** limit resolved backend opts to aliases by @risu729 in [#9315](#9315) - **(docs)** stack banner message and link on mobile by @jdx in [#9362](#9362) - **(github)** prefer shortest asset name as tiebreaker in auto-detection by @jdx in [#9361](#9361) - **(java)** newer zulu versions use a different directory structure by @roele in [#9365](#9365) - **(prune)** respect tracked lockfiles by @jdx in [#9373](#9373) - **(task)** skip tool install for missing naked tasks by @jdx in [#9374](#9374) - **(trust)** add untrust command by @jdx in [#9370](#9370) - fix - flux-operator-mcp aqua path by @monotek in [#9357](#9357) ### 📚 Documentation - update ruby compile msg by @fladson in [#9338](#9338) ### 📦️ Dependency Updates - update ubuntu docker tag to v26 by @renovate[bot] in [#9347](#9347) - update ghcr.io/jdx/mise:deb docker digest to 1af5a69 by @renovate[bot] in [#9352](#9352) - update taiki-e/install-action digest to 787505c by @renovate[bot] in [#9354](#9354) - update ghcr.io/jdx/mise:rpm docker digest to 7015ff3 by @renovate[bot] in [#9353](#9353) - update ghcr.io/jdx/mise:copr docker digest to da63a0f by @renovate[bot] in [#9351](#9351) - update ghcr.io/jdx/mise:alpine docker digest to 461700f by @renovate[bot] in [#9350](#9350) - bump communique 1.0.3 → 1.0.4 by @jdx in [#9378](#9378) ### 📦 Registry - remove openshift-install by @jdx in [#9372](#9372) - remove go-sdk by @jdx in [#9371](#9371) ### Chore - **(npm-publish)** use aube publish instead of npm publish by @jdx in [#9328](#9328) ### New Contributors - @fladson made their first contribution in [#9338](#9338)
## What - Add a shared backend option resolver that preserves where each effective option came from. - Resolve backend options in this order, with later layers overriding earlier ones: 1. Registry backend defaults. 2. Backend alias `[...]` options from `[tool_alias]` / `[alias]` backend entries. 3. Config options selected by the existing tool config lookup rules. 4. Inline backend options from the current tool spec, such as `tool[...]`. - Apply that resolved option path consistently in GitHub/GitLab/Forgejo, HTTP, S3, UBI, vfox backend plugins, Conda channel resolution, SPM provider/API URL resolution, Java release type listing, versions-host cache filtering, fuzzy version matching, `minimum_release_age` handling, runtime args, and install request initialization. - Preserve inline backend options across the short-name backend cache, so commands like `ls-remote 'github:owner/repo[api_url=...]'` do not accidentally use a cached installed backend without those inline options. - Preserve config options when runtime args include inline overrides, while still letting inline options win for the one command. - Switch Go install to use the resolved request options. - Fix shorthand parsing for URL-valued inline options such as `tool[api_url=https://example/api/v3]`. ## Follow-up The versions-host behavior for locally overridden backend options has been split into #9568. That PR is stacked on this one and should be rebased after this merges. ## Relationship to #9315 This PR does not change which config entry is eligible for a tool. That behavior comes from #9315: - Registry short names should not inherit config from their resolved full backend key. - Configured aliases can fall back to resolved full-backend config when there is no alias-specific entry. - Alias-specific `[tools.<alias>]` config is more specific than `[tools."<resolved-backend>"]` config. This PR builds on that lookup and changes what happens after config has been selected: registry defaults, backend alias options, config options, and inline options are merged through one resolver, with provenance retained for callers that need to distinguish where an option came from. ## Relationship to #8902 #8902 was a narrower `ls-remote` fix for inline backend options. This PR covers the same installed-tool cache failure mode generically: when a caller supplies inline backend options, mise builds a backend from that caller `BackendArg` instead of returning a short-name cache entry that was loaded from install state without the inline options. ## Example Given config selected through an alias fallback: ```toml [tool_alias] hw = "github:jdx/mise-test-fixtures[api_url=https://api.github.com]" [tools."github:jdx/mise-test-fixtures"] version = "1.0.0" asset_pattern = "definitely-not-a-real-hello-world-asset" ``` Inline options should still win for this invocation: ```sh mise install 'hw[asset_pattern=hello-world-1.0.0.tar.gz,bin_path=hello-world-1.0.0/bin]@1.0.0' ``` Before this PR, the resolved full-backend config could replace the inline `asset_pattern`, and alias `[...]` options were only visible as part of a resolved string. After this PR, alias options are their own layer and inline options are applied over the selected config options. ## Why Backend-level code had several config-or-inline branches. Depending on the path: - Inline options could be ignored when config existed for the same tool or resolved backend. - Inline options could be dropped at the installed-tool backend cache boundary. - Config options could be dropped when runtime args included inline options. - Backend alias `[...]` options were not represented as a distinct layer. - Backend-specific list/install paths could read raw backend args instead of the resolved tool options. - Registry defaults were not always part of the same overlay path as config and inline options. This PR centralizes that overlay so config-aware paths use the same precedence, while preserving source information separately from the effective option values. ## Validation - `cargo fmt --all` - `git diff --check` - `cargo test --all-features tool_opts` - `cargo test --all-features opts_with_config` - `cargo test --all-features test_git_provider_from_ba` - `mise run test:e2e e2e/backend/test_github_ls_remote_inline_opts` *This PR was updated by an AI coding assistant.* --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Suggested follow-up
Consider removing the remaining fallback where a configured
tool_aliaswith no[tools.<alias>]entry reads options from[tools."<resolved-backend>"]. That behavior is kept in this PR for compatibility, but it can be ambiguous once both the alias and resolved backend are configured:In that case, this PR treats
[tools.hw]as more specific and does not fall back to the resolved backend options.What changed
get_tool_optsso resolved full-backend config options are only considered for configured backend aliases/plugin aliases, not plain registry short-name resolution.[tools.<alias>]options whenever present.[tools.<alias>]entry can still use options from[tools."<resolved-backend>"].[email protected]from inheriting options configured under the resolved full backend key.[email protected]ignoring[tools."github:aquaproj/aqua"]options.[tools.<alias>].Examples
Registry short-name installs no longer inherit options from the resolved full backend key:
Configured backend aliases can still use options from the resolved full backend config when there is no alias-specific tool entry:
Alias-specific tool config remains more specific than the resolved full backend config:
Why
mise install [email protected]resolves the registry short nameaquatogithub:aquaproj/aqua. The previousget_tool_optsfallback looked up options by that resolved full backend even when the user requested the short registry name, causing options such asasset_patternfrom[tools."github:aquaproj/aqua"]to leak into the install.Configured backend aliases still need the resolved-full fallback for compatibility when there is no alias-specific tool entry. The fix narrows the fallback to configured aliases and keeps alias-specific config more specific whenever it exists.
Validation
mise run formatmise run test:e2e e2e/cli/test_install_short_ignores_full_backend_config e2e/backend/test_gitlab e2e/backend/test_github_tool_alias_asset_patternThis PR was updated by an AI coding assistant.