Skip to content

fix(backend): skip versions host for local tool opts#9568

Merged
jdx merged 8 commits intojdx:mainfrom
risu729:codex/versions-host-local-opt-sources
May 7, 2026
Merged

fix(backend): skip versions host for local tool opts#9568
jdx merged 8 commits intojdx:mainfrom
risu729:codex/versions-host-local-opt-sources

Conversation

@risu729
Copy link
Copy Markdown
Contributor

@risu729 risu729 commented May 3, 2026

This ignores settings, we still need to handle them later.

What

  • Keep the option-source-based versions-host behavior split out from fix(backend): apply inline tool option overrides #9306.
  • Skip mise-versions when a backend declares that a locally overridden tool option affects its remote version listing. Registry defaults still use the hosted list.
  • Keep locally safe options on the existing path: minimum_release_age / install_before still 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_url changes the GitHub-compatible API host queried for releases/tags; version_prefix changes which tags are considered versions.
  • ubi: provider changes the release provider implementation, api_url changes the API host, and tag_regex changes which tags are extracted as versions.
  • spm: provider changes the git hosting provider used for tags, and api_url changes the provider API host.
  • http: version_list_url changes the source document for versions, version_regex changes extraction from that document, version_json_path changes the JSON field read for versions, and version_expr changes the expression used to derive versions.
  • s3: version_list_url changes the manifest/listing source, version_regex changes extraction, version_json_path and version_expr change manifest parsing, version_prefix changes S3 object-list filtering, url can change the S3 bucket/key used for listing-based discovery, and region / endpoint change 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_type switches between GA and EA metadata caches, so it changes which Java releases appear.
  • conda: channel changes the Anaconda channel queried for package versions.

dotnet is intentionally deferred: prerelease currently 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 --check
  • git diff --check
  • cargo test backend::tests::test_remote_version_listing_opts
  • mise run test:e2e e2e/backend/test_github_alias_versions e2e/backend/test_github_ls_remote_inline_opts

This PR was updated by an AI coding assistant.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 3, 2026

Greptile Summary

This PR introduces per-backend remote_version_listing_tool_option_keys() declarations and uses source-tracked option resolution to skip the versions-host cache whenever a user-supplied option (from config, backend alias, or inline arg) can change what the backend returns from its upstream listing. Registry-sourced options are explicitly excluded so the cached list continues to be used for default registry tools.

  • src/backend/mod.rs adds the new trait method, VERSIONS_HOST_LOCAL_OPT_SOURCES, the has_local_version_listing_option_override helper, and two unit tests; it switches list_remote_versions_with_info_with_refresh from get_tool_opts_with_overrides to resolve_tool_opts_with_overrides to obtain source provenance.
  • Each backend (github, http, s3, ubi, spm, conda, java) declares the option keys that affect its remote version listing; dotnet and vfox return &[] with explicit TODO comments deferring their respective cases.

Confidence Score: 5/5

Safe 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

Comment thread src/cli/args/backend_arg.rs Outdated
Comment thread src/toolset/builder.rs
Comment thread e2e/backend/test_github_ls_remote_inline_opts
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 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.

Comment thread src/cli/args/backend_arg.rs Outdated
@risu729 risu729 force-pushed the codex/versions-host-local-opt-sources branch 2 times, most recently from e40573e to 51a060c Compare May 5, 2026 20:00
jdx pushed a commit that referenced this pull request May 5, 2026
## 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>
@risu729 risu729 force-pushed the codex/versions-host-local-opt-sources branch from 6c0d064 to 7791baa Compare May 5, 2026 20:31
Comment thread src/backend/mod.rs Outdated
@risu729
Copy link
Copy Markdown
Contributor Author

risu729 commented May 5, 2026

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.

@risu729

This comment was marked as outdated.

@risu729 risu729 marked this pull request as ready for review May 6, 2026 23:42
@jdx jdx enabled auto-merge (squash) May 7, 2026 00:00
@jdx jdx merged commit 606271a into jdx:main May 7, 2026
34 checks passed
@risu729 risu729 deleted the codex/versions-host-local-opt-sources branch May 7, 2026 00:15
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