fix(backend): skip versions host for local tool opts#9568
Conversation
Greptile SummaryThis PR introduces per-backend
Confidence Score: 5/5Safe to merge; the bypass logic is additive and only affects backends that already had broken behavior when local options changed their listing source. The core check uses a positive-match approach against each backend's declared listing keys, so install-time-only or filter-only options do not trigger a bypass. The layering order in resolve_tool_opts_with_overrides ensures local sources reliably win and are correctly labelled. src/backend/vfox.rs deferred case for custom backend plugins warrants a follow-up, but nothing in the current diff is blocking. Reviews (9): Last reviewed commit: "Merge branch 'main' into codex/versions-..." | Re-trigger Greptile |
There was a problem hiding this comment.
Code Review
This pull request refactors tool option resolution to ensure correct prioritization of inline CLI options, configuration files, and aliases across various backends. It introduces ResolvedToolOptions to track option sources, enabling more precise control over the versions host cache. Feedback was provided regarding the apply_overrides method, which currently fails to track sources for fields such as os, depends, and install_env.
e40573e to
51a060c
Compare
## 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>
6c0d064 to
7791baa
Compare
|
CI status after rebasing onto #9306/main: All non-registry checks completed successfully, including lint, Linux/Windows/macOS tests, benchmark, release, Socket, and Greptile Review. The registry workflow failed for unrelated infrastructure reasons. The failing registry test-tool shards show POOL_TOKEN empty / no API secret available, then GitHub API rate limiting with 403/429 responses while installing many unrelated registry tools. Example log messages include "No API secret provided, skipping token fetch", "GitHub core rate limit exceeded", and "HTTP status client error (403 Forbidden)" from api.github.com. The remaining registry shards were cancelled after those failures. I am treating the registry failure as unrelated to this PR. This comment was generated by an AI coding assistant. |
This ignores settings, we still need to handle them later.
What
mise-versionswhen a backend declares that a locally overridden tool option affects its remote version listing. Registry defaults still use the hosted list.minimum_release_age/install_beforestill use the existing before-date helper, and options that only affect install/download selection are not treated as version-listing inputs.Why These Tool Options Affect Remote Version Listing
These options change the upstream queried for versions, the way version candidates are extracted, or the release class included in the list:
github:api_urlchanges the GitHub-compatible API host queried for releases/tags;version_prefixchanges which tags are considered versions.ubi:providerchanges the release provider implementation,api_urlchanges the API host, andtag_regexchanges which tags are extracted as versions.spm:providerchanges the git hosting provider used for tags, andapi_urlchanges the provider API host.http:version_list_urlchanges the source document for versions,version_regexchanges extraction from that document,version_json_pathchanges the JSON field read for versions, andversion_exprchanges the expression used to derive versions.s3:version_list_urlchanges the manifest/listing source,version_regexchanges extraction,version_json_pathandversion_exprchange manifest parsing,version_prefixchanges S3 object-list filtering,urlcan change the S3 bucket/key used for listing-based discovery, andregion/endpointchange which S3-compatible service is queried.vfox: backend plugins can define arbitrary option semantics and pass them into plugin version-listing logic, so custom vfox backend plugins use the all-options sentinel. Regular vfox plugins keep the default hosted-list behavior.java:release_typeswitches between GA and EA metadata caches, so it changes which Java releases appear.conda:channelchanges the Anaconda channel queried for package versions.dotnetis intentionally deferred:prereleasecurrently changes the NuGet query, but there are no dotnet backend tools in the registry using the versions host. The code now carries a TODO to revisit this when dotnet can list the prerelease superset and filter at read time like github/aqua.Validation
cargo fmt --checkgit diff --checkcargo test backend::tests::test_remote_version_listing_optsmise run test:e2e e2e/backend/test_github_alias_versions e2e/backend/test_github_ls_remote_inline_optsThis PR was updated by an AI coding assistant.