Skip to content

fix(task): align duplicate config task precedence#10471

Merged
jdx merged 3 commits into
jdx:mainfrom
risu729:codex-20260616-032249-52a4e1
Jun 16, 2026
Merged

fix(task): align duplicate config task precedence#10471
jdx merged 3 commits into
jdx:mainfrom
risu729:codex-20260616-032249-52a4e1

Conversation

@risu729

@risu729 risu729 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve the highest-precedence TOML task when multiple config files define the same task name in one config root.
  • Keep the existing TOML-overlay behavior for file tasks, so script-backed tasks can still receive metadata from [tasks.<name>].
  • Add an e2e regression for .config/mise.toml plus .mise/config.toml duplicate task definitions.

Context

Investigates project item 190217576 / discussion #9947. The bug was still real on current main: mise tasks listed .config/a, while mise run a executed .mise/a.

Verification

  • cargo fmt
  • cargo build --bin mise --all-features
  • e2e/run_test tasks/test_task_config_precedence
  • e2e/run_test tasks/test_task_file_toml_merge
  • manual reproduction of duplicate .config/mise.toml and .mise/config.toml task definitions

Summary by CodeRabbit

  • Bug Fixes

    • Fixed task configuration merging so conflicting task definitions follow the correct precedence rules, ensuring higher-priority TOML values are respected.
  • Tests

    • Added a new end-to-end test that creates two competing task config files for the same task key and verifies that both task listing and execution use the expected (higher-priority) configuration values.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: c423b635-9d6c-403d-989d-68b5cf5c0928

📥 Commits

Reviewing files that changed from the base of the PR and between 015b147 and b269811.

📒 Files selected for processing (1)
  • src/config/mod.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/config/mod.rs

📝 Walkthrough

Walkthrough

merge_file_and_config_tasks in src/config/mod.rs now gates merge_toml_overlay on existing.file.is_some() for name-colliding tasks. Unit test fixtures are updated to include the file field on Windows sibling tasks. A new e2e test creates two competing config files with the same task key and asserts that .mise/config.toml takes precedence over .config/mise.toml.

Changes

Task Config Precedence Fix

Layer / File(s) Summary
Precedence logic and documentation
src/config/mod.rs
merge_toml_overlay is now only called when existing.file.is_some(), preventing overlay application for inline/config tasks on name collision. The doc comment for merge_file_and_config_tasks is updated to describe this conditional overlay behavior and clarify precedence semantics.
Test fixture alignment and e2e validation
src/config/mod.rs, e2e/tasks/test_task_config_precedence
The Windows sibling test fixture (.ps1 case) is updated to include file: Some(...) to align with the new gating logic. A new e2e test creates .config/mise.toml and .mise/config.toml with the same tasks.a key and asserts .mise/config.toml wins for both task listing and execution output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • jdx/mise#10443: Modifies the same merge_file_and_config_tasks function in src/config/mod.rs, affecting TOML overlay behavior for colliding file-discovered and config tasks.
  • jdx/mise#10191: Also changes task-merging precedence logic in merge_file_and_config_tasks, directly related to how [tasks.*] overlays interact with file/git-discovered tasks on name collision.

Poem

🐇 Two configs walked in, both claiming the same name,
.mise/config.toml said "I win this game!"
The overlay now checks — does a file exist here?
If not, step aside and let precedence be clear.
With one guarded if, the rabbit hops right! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(task): align duplicate config task precedence' clearly and accurately summarizes the main change: fixing task precedence inconsistency when multiple config files define the same task name.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a task-precedence bug where two inline [tasks.<name>] blocks from different config files at the same config root (e.g. .mise/config.toml and .config/mise.toml) would let the lower-precedence file's definition bleed through via merge_toml_overlay. The one-line guard existing.file.is_some() ensures that the overlay path is only taken for script-backed or TOML-include file tasks; pure inline config tasks now follow "first entry wins" (highest precedence first).

  • Core fix (src/config/mod.rs): merge_file_and_config_tasks now skips merge_toml_overlay when the already-inserted task has no backing file, so a lower-priority config's inline [tasks.*] block cannot overwrite a higher-priority one.
  • Test fixtures updated: unit-test Task structs that represent file tasks now set file: Some(...) so the new guard fires correctly in existing tests.
  • New e2e regression (e2e/tasks/test_task_config_precedence): creates the exact duplicate-config scenario from issue tasks merging does not work as expected #9947 and asserts both mise tasks output and mise run execution use the .mise/config.toml definition.

Confidence Score: 5/5

Safe to merge — the change is a minimal, well-targeted guard in a single branch of merge_file_and_config_tasks, backed by both an updated unit test and a new e2e regression that reproduces the exact original bug.

The changed code path is a single added condition; the existing TOML-overlay behaviour for file-backed tasks is fully preserved, and the 'first config wins' behaviour for duplicate inline blocks matches the documented precedence ordering already established by configs_at_root. Unit tests were updated to reflect the new requirement and the e2e test directly covers the regression scenario.

No files require special attention.

Important Files Changed

Filename Overview
src/config/mod.rs Adds existing.file.is_some() guard in merge_file_and_config_tasks so that TOML overlay only applies to script/TOML-include file tasks; a pure config task (file=None) from a lower-precedence config file no longer clobbers the higher-precedence one. Unit tests updated to set file: Some(...) on file-task fixtures so the guard fires correctly.
e2e/tasks/test_task_config_precedence New e2e regression test: creates competing .config/mise.toml and .mise/config.toml task definitions and asserts that mise tasks and mise run both reflect the higher-precedence .mise/config.toml definition.

Reviews (2): Last reviewed commit: "docs(task): update merge_file_and_config..." | Re-trigger Greptile

@github-actions

Copy link
Copy Markdown

This PR currently has failing checks. If this continues for 7 days, it will be closed automatically.

This is warning day 1 of 7.

Please update the PR when you have a chance. Feel free to reopen or create a new PR if it is closed and you'd like to continue working on it.

This comment was generated by an automated workflow.

risu729 added 2 commits June 17, 2026 05:23
The merge guard only overlays TOML metadata onto file-backed tasks,
so the unit test mocks need `file` set like real discovered scripts.
Document the file.is_some() overlay guard and multi-config inline
task precedence so the comment matches current behavior.
@risu729 risu729 marked this pull request as ready for review June 16, 2026 19:37
@jdx jdx merged commit adfa5b5 into jdx:main Jun 16, 2026
33 checks passed
@risu729 risu729 deleted the codex-20260616-032249-52a4e1 branch June 16, 2026 23:25
This was referenced Jun 16, 2026
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