Skip to content

feat(backend): support aqua vars templates#9110

Merged
jdx merged 9 commits intojdx:mainfrom
risu729:copilot/aqua-vars
Apr 21, 2026
Merged

feat(backend): support aqua vars templates#9110
jdx merged 9 commits intojdx:mainfrom
risu729:copilot/aqua-vars

Conversation

@risu729
Copy link
Copy Markdown
Contributor

@risu729 risu729 commented Apr 15, 2026

Summary

  • add support for aqua registry vars definitions in the aqua backend
  • render string vars as .Vars.<name> in aqua templates, including function arguments and chained property access
  • accept string vars from tool options as either vars = { name = "value" } or flat name = "value" keys
  • apply aqua-style required/default validation, while rejecting non-string var values with a focused error
  • include aqua string var options in lockfile artifact identity and bin-path cache keys so different var values do not reuse stale resolution data
  • document aqua vars options and required/default behavior

Background

  • Fixes Aqua backend doesn't handle `vars` in aqua registry #7160.
  • Aqua added registry vars in v2.31.0 via feat: add vars aquaproj/aqua#3052.
  • Aqua registry vars are exposed to templates as .Vars.<name> and can declare required and default fields; aqua applies defaults and errors when a required var has no value/default.
  • Current registry entries that need this include:
    • aqua:flutter/flutter, which uses .Vars.channel with default stable
    • aqua:scenarigo/scenarigo, which uses required .Vars.go_version

Difference From Aqua

  • Upstream aqua stores package vars as map[string]any and passes that map directly into Go templates, so arrays/objects/non-string scalar values can exist there.
  • mise's aqua registry renderer is string-oriented: template expansion ultimately resolves artifact names, URLs, and file paths as strings, and lockfile option identity is also string-valued.
  • This PR intentionally supports only string aqua var values/defaults. Non-string values such as arrays or objects now fail with an explicit error like aqua var \vars.fixture_version` must be a string, got array`.
  • This keeps the implementation narrow for the registry entries this PR targets, instead of reimplementing Go template value semantics.

Implementation Notes

  • crates/aqua-registry models vars, validates missing required vars, and accepts string defaults only.
  • The aqua backend maps mise tool options into string aqua var values before resolving assets, lockfile entries, installs, and bin paths.
  • Nested vars = { name = "value" } wins over flat name = "value", and both forms canonicalize to the same lockfile option identity.

Tests

  • cargo fmt --check
  • git diff --check -- . ':!mise.lock'
  • cargo test -p aqua-registry
  • cargo test backend::aqua::tests::
  • mise run test:e2e e2e/backend/test_aqua_vars

This PR was originally generated by Copilot and updated after manual review.

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 implements support for template variables (vars) within the aqua backend. Key changes include updating the template lexer and parser to handle chained property access, extending the AquaPackage model to support variable definitions with defaults and requirement checks, and integrating these variables into the tool installation process via tool options. Documentation and unit tests have been added to cover the new functionality. A review comment suggests refactoring duplicated identifier parsing logic in the template lexer to improve maintainability.

Comment thread crates/aqua-registry/src/template.rs Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 15, 2026

Greptile Summary

This PR adds support for aqua registry vars template substitutions in the mise aqua backend, enabling tools like aqua:flutter/flutter ({{.Vars.channel}}) and aqua:scenarigo/scenarigo ({{.Vars.go_version}}) to work correctly. Users can provide var values as flat top-level keys or via a nested vars = {} table; both forms canonicalize to the same \"vars.key\" identity in the lockfile. The template engine is extended to resolve chained .Vars.name property access, and only string var values are accepted.

All remaining findings are P2: serde_yaml::Value::Null in a registry default is converted to an empty string instead of being treated as absent (diverging from Go aqua), and non-string scalars inside the nested vars = {} table fail type-checking while equivalent flat-key scalars are silently coerced by the TOML parser.

Confidence Score: 5/5

Safe to merge; no P0/P1 issues found, all remaining findings are P2 edge-case observations

The implementation is well-scoped and correctly handles the primary use cases. The two P2 findings are edge cases that don't affect real aqua registry entries. Test coverage (unit + e2e) is thorough.

crates/aqua-registry/src/types.rs (Null handling) and src/backend/aqua.rs (scalar coercion asymmetry)

Important Files Changed

Filename Overview
crates/aqua-registry/src/types.rs Adds vars support to AquaPackage with with_var_values/vars_ctx/validate_vars; Null default treated as empty string rather than absent
crates/aqua-registry/src/template.rs Extends lexer to tokenise chained .Vars.name property access and adds eval_property shortcut for flat context keys
src/backend/aqua.rs Adds apply_var_options, lockfile_options, aqua_var_option, toml_string_var; nested vars={} wins over flat keys; non-string scalars in nested table fail while flat scalars are coerced
e2e/backend/test_aqua_vars E2e test covering flat-key vars, nested vars table, lockfile canonicalization, and array-value rejection
docs/dev-tools/backends/aqua.md Adds vars option documentation with both flat-key and nested-table syntax examples
crates/aqua-registry/src/lib.rs Re-exports AquaVar from types for use by the aqua backend
src/toolset/tool_version_options.rs Unchanged in substance; existing scalar-to-string coercion in try_parse_as_toml is the source of the flat-key/nested-table asymmetry

Sequence Diagram

sequenceDiagram
    participant Config as mise.toml
    participant Backend as AquaBackend
    participant Registry as AquaRegistry
    participant Pkg as AquaPackage
    participant Template as template::render

    Config->>Backend: options with channel or vars={channel}
    Backend->>Registry: package_with_version(id, versions)
    Registry-->>Backend: AquaPackage with vars declared
    Backend->>Backend: apply_var_options(pkg, opts)
    note over Backend: nested vars{} wins over flat key
    Backend->>Pkg: with_var_values({channel:stable})
    Pkg->>Pkg: validate_vars()
    Pkg-->>Backend: AquaPackage with var_values set
    Backend->>Pkg: asset(v, os, arch)
    Pkg->>Pkg: vars_ctx() builds Vars.channel context
    Pkg->>Template: render template with ctx
    Template-->>Pkg: resolved asset string
    Backend->>Backend: lockfile_options(opts)
    note over Backend: all non-excluded keys prefixed vars.
    Backend-->>Config: lockfile entry vars.channel=stable
Loading

Reviews (9): Last reviewed commit: "test(backend): suppress aqua vars shellc..." | Re-trigger Greptile

Comment thread crates/aqua-registry/src/types.rs Outdated
@risu729 risu729 marked this pull request as ready for review April 18, 2026 07:40
@risu729 risu729 marked this pull request as draft April 18, 2026 07:42
@risu729
Copy link
Copy Markdown
Contributor Author

risu729 commented Apr 19, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59c25a91c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/aqua-registry/src/types.rs
Comment thread src/backend/aqua.rs
@risu729 risu729 marked this pull request as ready for review April 20, 2026 19:22
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@risu729 risu729 marked this pull request as draft April 20, 2026 19:23
@risu729 risu729 marked this pull request as ready for review April 21, 2026 04:42
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@jdx jdx merged commit 60e2d5d into jdx:main Apr 21, 2026
35 checks passed
@risu729 risu729 deleted the copilot/aqua-vars branch April 21, 2026 18:18
jdx pushed a commit that referenced this pull request Apr 22, 2026
### 🚀 Features

- **(backend)** support aqua vars templates by @risu729 in
[#9110](#9110)
- add gsudo (Sudo for Windows) to registry by @matracey in
[#9281](#9281)

### 🐛 Bug Fixes

- **(cli)** retrieve token from github helper for `self-update` command
by @sushichan044 in [#9259](#9259)
- **(github)** scope auth headers to API URLs by @risu729 in
[#9271](#9271)
- **(vfox)** use github token for lua http requests by @jdx in
[#9257](#9257)

### 📚 Documentation

- add aube hero banner by @jdx in
[#9265](#9265)
- add en.dev footer by @jdx in
[#9267](#9267)
- implement landing page design by @jdx in
[#9266](#9266)

### 📦️ Dependency Updates

- lock file maintenance by @renovate[bot] in
[#9268](#9268)

### 📦 Registry

- add llama.cpp
([github:ggml-org/llama.cpp](https://github.com/ggml-org/llama.cpp)) by
@igor-makarov in [#9282](#9282)
- add kiro-cli by @shalk in
[#9274](#9274)
- add flux-operator & flux-operator-mcp by @monotek in
[#8852](#8852)

### Chore

- **(release)** add en.dev sponsor blurb to release notes by @jdx in
[#9272](#9272)
- bump communique to 1.0.1 by @jdx in
[#9264](#9264)

### New Contributors

- @monotek made their first contribution in
[#8852](#8852)
- @igor-makarov made their first contribution in
[#9282](#9282)

## 📦 Aqua Registry Updates

#### New Packages (2)

-
[`controlplaneio-fluxcd/flux-operator/flux-operator-mcp`](https://github.com/controlplaneio-fluxcd/flux-operator/flux-operator-mcp)
- [`endevco/aube`](https://github.com/endevco/aube)

#### Updated Packages (1)

- [`graelo/pumas`](https://github.com/graelo/pumas)
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