Skip to content

fix(tasks): respect env precedence for task config#9039

Merged
jdx merged 2 commits intojdx:mainfrom
risu729:task-includes-env-precedence-test
Apr 11, 2026
Merged

fix(tasks): respect env precedence for task config#9039
jdx merged 2 commits intojdx:mainfrom
risu729:task-includes-env-precedence-test

Conversation

@risu729
Copy link
Copy Markdown
Contributor

@risu729 risu729 commented Apr 10, 2026

Summary

Fixes task_config precedence when multiple MISE_ENV values are active.

configs_at_root returns config files highest-precedence first, but the task include resolver reversed that list before selecting the first explicit task_config.includes. With MISE_ENV=prod,ci, that made mise.prod.toml win over mise.ci.toml, contrary to the documented last-env-wins behavior.

The fix applies the same precedence order to local includes, remote git:: includes, and task_config.dir selection. The e2e test now covers both include replacement and dir precedence.

Verification

  • cargo build
  • cargo fmt --check
  • git diff --check
  • e2e/run_test tasks/test_task_includes_env_precedence
  • e2e/run_test config/test_config_env
  • e2e/run_test env/test_env_profiles
  • e2e/run_test tasks/test_task_mise_env_profiles

@risu729 risu729 marked this pull request as draft April 10, 2026 21:48
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 10, 2026

Greptile Summary

This PR adds an e2e test covering task_config.includes precedence when multiple MISE_ENV values are set, and fixes the underlying bug by removing the .rev() calls that were double-reversing the configs_at_root ordering. The test verifies that for MISE_ENV=prod,ci, mise.ci.toml (last env = highest precedence) fully replaces mise.prod.toml's includes.

The fix is logically sound: DEFAULT_CONFIG_FILENAMES appends env-specific filenames in MISE_ENV order (prod first, ci last), and configs_at_root already reverses that list so highest-precedence configs come first. The old .rev().find_map() chains were accidentally re-reversing that ordering, causing the lowest-precedence config to win instead. Removing all three .rev() calls corrects the behavior consistently across task_includes_for_dir and load_tasks_in_dir.

  • The PR description says "only adds a failing test," but the diff also includes the fix in src/config/mod.rs. The description should be updated to reflect the full scope of the change.

Confidence Score: 5/5

Safe to merge — the fix correctly removes double-reversal, the test validates the intended semantics, and CI will pass with both changes included.

All findings are P2 (optional inverse-direction test coverage). The core fix is logically correct: DEFAULT_CONFIG_FILENAMES appends envs in MISE_ENV order so .rev() in configs_at_root already places highest-precedence first; removing the three .rev().find_map() chains eliminates the inadvertent double-reversal. No P0/P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
e2e/tasks/test_task_includes_env_precedence New e2e test that creates prod/ci env-specific configs and asserts ci-task wins with MISE_ENV=prod,ci; correctly validates both task listing and task execution directory.
src/config/mod.rs Removes three .rev() calls from task_includes_for_dir and load_tasks_in_dir that were double-reversing the already-highest-precedence-first ordering from configs_at_root, plus adds a clarifying comment to that function.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["configs_at_root(dir)"] -->|"DEFAULT_CONFIG_FILENAMES.iter().rev()"| B["configs ordered: highest-precedence first\ne.g. [mise.ci.toml, mise.prod.toml, mise.toml]"]
    B --> C{"task_includes_for_dir"}
    C -->|"configs.iter().find_map()"| D["First match = mise.ci.toml\n(task_config.includes = ['ci-tasks'])"]
    D --> E["Only ci-tasks resolved\nprod-tasks ignored"]
    B --> F{"load_tasks_in_dir"}
    F -->|"configs.iter().find_map()"| G["First match = mise.ci.toml\n(git includes, task_config.dir)"]
    G --> H["ci-work dir used\nfor all file tasks"]

    style D fill:#d4edda
    style E fill:#d4edda
    style G fill:#d4edda
    style H fill:#d4edda
Loading

Reviews (2): Last reviewed commit: "fix(tasks): respect env precedence for t..." | Re-trigger Greptile

Comment thread e2e/tasks/test_task_includes_env_precedence
Comment thread e2e/tasks/test_task_includes_env_precedence
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 introduces an end-to-end test to verify the precedence of environment-specific task configurations in mise. The test ensures that when multiple environments are active, task inclusions from the higher-precedence environment are correctly prioritized. I have no feedback to provide.

@risu729 risu729 changed the title test(tasks): cover env task include precedence fix(tasks): respect env precedence for task config Apr 11, 2026
@risu729 risu729 marked this pull request as ready for review April 11, 2026 01:23
@jdx jdx merged commit 8638a4c into jdx:main Apr 11, 2026
35 checks passed
@risu729 risu729 deleted the task-includes-env-precedence-test branch April 11, 2026 12:25
mise-en-dev added a commit that referenced this pull request Apr 11, 2026
### 🐛 Bug Fixes

- **(docs)** upgrade esbuild to 0.28.0 with es2022 build target by @jdx
in [#9047](#9047)
- **(env)** skip tools=true module hooks in dependency_env by @jdx in
[#9011](#9011)
- **(lockfile)** resolve SLSA provenance URLs deterministically for all
platforms by @cameronbrill in
[#8982](#8982)
- **(registry)** test of docuum in registry by @jylenhof in
[#8996](#8996)
- **(release)** publish extracted mise.exe alongside Windows zip by
@zeitlinger in [#8997](#8997)
- **(schema)** add missing config fields by @risu729 in
[#9044](#9044)
- **(task)** support sandbox fields in task templates by @risu729 in
[#9046](#9046)
- **(tasks)** respect env precedence for task config by @risu729 in
[#9039](#9039)
- prevent implicit enabling of `self_update` when rustls features are
enabled by @salim-b in [#9040](#9040)
- allow installing bun and others when downloads folder is on a
different mount by @bgeron in
[#9032](#9032)

### 📚 Documentation

- discourage direnv compatibility PRs and remove issue suggestions by
@jdx in
[ca78346](ca78346)
- tighten direnv compatibility language by @jdx in
[ab140c8](ab140c8)
- add Tera tip for unsupported version files by @risu729 in
[#9048](#9048)

### 📦️ Dependency Updates

- update ghcr.io/jdx/mise:deb docker digest to 49fa8a4 by @renovate[bot]
in [#8999](#8999)
- update ghcr.io/jdx/mise:copr docker digest to 61ba7b6 by
@renovate[bot] in [#8998](#8998)
- update ghcr.io/jdx/mise:copr docker digest to fa351ff by
@renovate[bot] in [#9002](#9002)
- update ghcr.io/jdx/mise:alpine docker digest to f3bb475 by
@renovate[bot] in [#9001](#9001)
- update ghcr.io/jdx/mise:rpm docker digest to d45af2d by @renovate[bot]
in [#9005](#9005)
- update ghcr.io/jdx/mise:deb docker digest to d7463ac by @renovate[bot]
in [#9004](#9004)
- update jdx/mise-action digest to 5228313 by @renovate[bot] in
[#9007](#9007)
- update rust docker digest to e8e2bb5 by @renovate[bot] in
[#9008](#9008)
- update taiki-e/install-action digest to 97a5807 by @renovate[bot] in
[#9010](#9010)
- update autofix-ci/action action to v1.3.3 by @renovate[bot] in
[#9015](#9015)
- update ubuntu:24.04 docker digest to 84e77de by @renovate[bot] in
[#9012](#9012)
- update actions/checkout action to v4.3.1 by @renovate[bot] in
[#9014](#9014)
- update ubuntu:26.04 docker digest to cc925e5 by @renovate[bot] in
[#9013](#9013)
- update rust crate tokio to v1.51.1 by @renovate[bot] in
[#9018](#9018)
- update rust crate zip to v8.5.1 by @renovate[bot] in
[#9019](#9019)
- update rust crate ctor to 0.9 by @renovate[bot] in
[#9024](#9024)
- update ubuntu docker tag to resolute-20260404 by @renovate[bot] in
[#9020](#9020)
- update dependency vitepress-plugin-tabs to ^0.8.0 by @renovate[bot] in
[#9023](#9023)
- update rust crate indexmap to v2.14.0 by @renovate[bot] in
[#9025](#9025)
- update rust crate nix to 0.31 by @renovate[bot] in
[#9030](#9030)
- update taiki-e/install-action digest to 7a4939c by @renovate[bot] in
[#9027](#9027)
- update dependency esbuild to v0.28.0 by @renovate[bot] in
[#9022](#9022)
- update rust crate rand to 0.10 by @renovate[bot] in
[#9031](#9031)
- update rust crate digest to 0.11.0 by @renovate[bot] in
[#9028](#9028)
- update rust crate confique to 0.4 by @renovate[bot] in
[#9026](#9026)
- update rust crate rattler to 0.40 by @renovate[bot] in
[#9034](#9034)
- lock file maintenance by @renovate[bot] in
[#8416](#8416)
- disable renovate for aws-config/aws-sdk-* crates by @jdx in
[#9052](#9052)
- update swatinem/rust-cache digest to e18b497 by @renovate[bot] in
[#9009](#9009)

### 📦 Registry

- remove broken tool tests by @jdx in
[#9017](#9017)
- update granted aqua backend repo by @risu729 in
[#9033](#9033)
- fix atlas-community test expected output by @jdx in
[#9054](#9054)

### Chore

- use deprecated_at! macro for ubi backend deprecation by @jdx in
[#9049](#9049)

### Security

- **(ci)** run test-tool inside Docker container by @jdx in
[#9055](#9055)
- **(ci)** avoid exposing MISE_GH_TOKEN to test-tool scripts by @jdx in
[#9053](#9053)

### New Contributors

- @bgeron made their first contribution in
[#9032](#9032)
- @salim-b made their first contribution in
[#9040](#9040)

## 📦 Aqua Registry Updates

#### Updated Packages (2)

-
[`cloudnative-pg/cloudnative-pg/kubectl-cnpg`](https://github.com/cloudnative-pg/cloudnative-pg/kubectl-cnpg)
- [`gleam-lang/gleam`](https://github.com/gleam-lang/gleam)
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