Skip to content

fix(task): render dependency templates even when no args are passed#9062

Merged
jdx merged 2 commits intojdx:mainfrom
MatthiasGrandl:fix-default-args-depends
Apr 12, 2026
Merged

fix(task): render dependency templates even when no args are passed#9062
jdx merged 2 commits intojdx:mainfrom
MatthiasGrandl:fix-default-args-depends

Conversation

@MatthiasGrandl
Copy link
Copy Markdown
Contributor

Summary

  • Fix {{usage.*}} templates in depends not being rendered when the task is invoked without arguments
  • The !task.args.is_empty() guard in both run.rs and deps.rs prevented template rendering when no CLI args were passed, even though the usage spec may define defaults
  • Dependencies with unrendered {{usage.*}} templates were silently dropped, causing the task to run with no dependencies at all

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 modifies the dependency rendering logic to support default usage values by removing the requirement that a task must have explicit arguments. In both src/cli/run.rs and src/task/deps.rs, the code now attempts to parse usage values even when args is empty, allowing {{usage.*}} templates to resolve correctly. The reviewer suggested optimizing the implementation in src/cli/run.rs by adding a guard to check for the existence of usage templates before parsing, which avoids unnecessary processing for tasks that do not use them.

Comment thread src/cli/run.rs Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 12, 2026

Greptile Summary

Removes the !task.args.is_empty() / !a.args.is_empty() guards from the {{usage.*}} dependency-template rendering paths in both run.rs and deps.rs. The guards were preventing parse_usage_values_from_task from running when no CLI args were passed, even though the usage spec may define defaults; this caused deps with unrendered templates to be silently filtered out. The fix correctly scopes the work to tasks that actually contain usage-template references via the existing has_usage_deps predicate.

Confidence Score: 5/5

Safe to merge — the fix is narrowly scoped, logically correct, and has no regressions on existing tests.

Both changes are symmetric and minimal: they replace an overly-restrictive args.is_empty() guard with the already-existing has_usage_deps predicate. The only remaining finding is a P2 test gap for the specific default-value scenario, which does not affect correctness of the existing test suite.

No files require special attention.

Important Files Changed

Filename Overview
src/cli/run.rs Replaces the !task.args.is_empty() guard with a has_usage_deps check, mirroring the fix in deps.rs and correctly scoping template re-rendering to tasks that actually have usage-template dependencies.
src/task/deps.rs Removes the !a.args.is_empty() guard from the dep-template-rendering block, allowing parse_usage_values_from_task to run (and pick up default values) even when no CLI args were passed to the task.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Task invoked] --> B{has_usage_deps\nin depends/wait_for?}
    B -- No --> G[resolve_depends\nskips usage templates]
    B -- Yes --> C[parse_usage_values_from_task\nparses spec + applies defaults]
    C --> D{usage_values\nempty?}
    D -- Yes\nno defaults/required arg missing --> G
    D -- No --> E[render_depends_with_usage\nreplaces usage.* templates]
    E --> F[resolve_depends\nmatches resolved dep names]
    G --> H[Tasks run without rendered deps]
    F --> I[Tasks run with correct deps]

    style H fill:#ffcccc
    style I fill:#ccffcc
Loading

Reviews (3): Last reviewed commit: "[autofix.ci] apply automated fixes" | Re-trigger Greptile

Comment thread src/cli/run.rs
@MatthiasGrandl MatthiasGrandl force-pushed the fix-default-args-depends branch from 602b819 to 5627ac8 Compare April 12, 2026 12:04
@jdx jdx enabled auto-merge (squash) April 12, 2026 12:20
@jdx jdx merged commit d1d1e52 into jdx:main Apr 12, 2026
34 checks passed
KOBeerose pushed a commit to KobeTools/mise that referenced this pull request Apr 13, 2026
…dx#9062)

## Summary
- Fix `{{usage.*}}` templates in `depends` not being rendered when the
task is invoked without arguments
- The `!task.args.is_empty()` guard in both `run.rs` and `deps.rs`
prevented template rendering when no CLI args were passed, even though
the usage spec may define defaults
- Dependencies with unrendered `{{usage.*}}` templates were silently
dropped, causing the task to run with no dependencies at all

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
mise-en-dev added a commit that referenced this pull request Apr 13, 2026
### 🐛 Bug Fixes

- **(docs)** typo in Go Backend by @dolmen in
[#9065](#9065)
- **(task)** render dependency templates even when no args are passed by
@MatthiasGrandl in [#9062](#9062)
- support npm semver ranges in devEngines by @risu729 in
[#9061](#9061)

### New Contributors

- @dolmen made their first contribution in
[#9065](#9065)
- @MatthiasGrandl made their first contribution in
[#9062](#9062)
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