Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requires returns inconsistent results for dynamic variables depending upon whether or not enum is specified #2032

Open
mmiddletonatua opened this issue Jan 31, 2025 · 1 comment · May be fixed by #2033
Assignees
Labels
area: variables Changes related to variables.

Comments

@mmiddletonatua
Copy link

Description

Running the task as defined in the example results in the error:

task: Task "init_env" cancelled because it is missing required variables:
  - ENVIRONMENT has an invalid value : '' (allowed values : [dev stage prod])

Changing the requires section to:

    requires:
      vars: [ENVIRONMENT]

results in the expected behavior:
task: [init_env] echo ENVIRONMENT is dev
ENVIRONMENT is dev

This appears to be a regression as things previously behaved as expected.

Version

3.41.0

Operating system

Ubuntu 22.04.1

Experiments Enabled

No response

Example Taskfile

version: '3'

vars:
  ENVIRONMENT:
    sh: basename a/directory/named/dev

tasks:
  init_env:
    cmds:
      - echo ENVIRONMENT is {{.ENVIRONMENT}}

    requires:
      vars:
      - name: ENVIRONMENT
        enum: [dev, stage, prod]
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Jan 31, 2025
@trulede
Copy link

trulede commented Jan 31, 2025

@mmiddletonatua @vmaerten I think commit d64df3f broke this. The required check was moved to a location before a Task is compiled, and as a result, the sh command is not evaluated at the time of the require check. The code here

value, isString := value.Value.(string)
has an empty string value, and the following check fails.

With version 3.40.0, your taskfile works.

@vmaerten vmaerten added area: variables Changes related to variables. and removed state: needs triage Waiting to be triaged by a maintainer. labels Feb 2, 2025
@vmaerten vmaerten self-assigned this Feb 2, 2025
@vmaerten vmaerten linked a pull request Feb 2, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: variables Changes related to variables.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants