You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But when running task --interactive deploy, a free-form text prompt is shown instead of the api/web/db selection menu. Pressing enter without typing anything then fails with a confusing error:
task: Task "deploy-dynamic" cancelled because it is missing required variables:
- SERVICE has an invalid value : '' (allowed values : [api web db])
This is a remaining gap of the fix from #2927 (which closed #2817): that fix resolves enum.ref against the fast-compiled task vars, where sh: variables are not evaluated and resolve to "". The ref then produces an empty list, so input.Prompter.Prompt falls back to Text.
The values are resolvable though: running non-interactively works and validation lists the allowed values (as shown in the error above), so the menu could be built from them.
task --interactive deploy
# Expected: selection menu with api/web/db# Actual: free-form text input
A static ref (ref: .ALLOWED_ENVS where ALLOWED_ENVS: [dev, staging, prod]) does show the selection menu correctly.
Impact
Contradicts the docs and the changelog entry for feat: support enum.ref in interactive prompts #2927 ("enum.ref now show the selection list like static enums, instead of falling back to free-form input").
Affects deps too, since promptDepsVars resolves their enum refs the same way.
The guide's own examples for dynamic enum refs are exactly the affected case.
Proposed fix
In resolveEnumRefForPrompt (requires.go), evaluate the referenced dynamic (sh:) variables before resolving the ref so the enum list is populated and a Select menu is shown.
Description
The guide documents that enum refs can reference dynamically-computed variables:
https://taskfile.dev/docs/guide#using-variable-references-for-enum-values
And the interactive-mode docs say "For variables with an
enum, a selection menu is shown":https://taskfile.dev/docs/guide#prompting-for-missing-variables-interactively
But when running
task --interactive deploy, a free-form text prompt is shown instead of the api/web/db selection menu. Pressing enter without typing anything then fails with a confusing error:This is a remaining gap of the fix from #2927 (which closed #2817): that fix resolves
enum.refagainst the fast-compiled task vars, wheresh:variables are not evaluated and resolve to"". The ref then produces an empty list, soinput.Prompter.Promptfalls back toText.The values are resolvable though: running non-interactively works and validation lists the allowed values (as shown in the error above), so the menu could be built from them.
Steps to reproduce
A static ref (
ref: .ALLOWED_ENVSwhereALLOWED_ENVS: [dev, staging, prod]) does show the selection menu correctly.Impact
promptDepsVarsresolves their enum refs the same way.Proposed fix
In
resolveEnumRefForPrompt(requires.go), evaluate the referenced dynamic (sh:) variables before resolving the ref so the enum list is populated and aSelectmenu is shown.