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

v3.40.0 behaviour change with undefined/null variables passed into ref #1911

Open
kirkrodrigues opened this issue Nov 7, 2024 · 0 comments
Labels
state: needs triage Waiting to be triaged by a maintainer.

Comments

@kirkrodrigues
Copy link
Contributor

Before v3.40.0, when passing a variable into another variable using the ref attribute, undefined and null variables were treated as empty lists. Now, they seem to be treated as empty strings. Which is the expected behavior?

Taskfile that illustrates the problem
version: "3"

vars:
  EMPTY_LIST_VAR: []
  EMPTY_STR_VAR: ""
  NULL_VAR: null

tasks:
  loop_and_echo_var:
    cmd: >-
      {{range .ECHO_VAR}}
      echo {{.}}
      {{end}

  test1:
    cmds:
      - echo "UNDEFINED_VAR"
      - task: loop_and_echo_var
        vars:
          ECHO_VAR:
            ref: ".UNDEFINED_VAR"

  test2:
    cmds:
      - echo "EMPTY_LIST_VAR"
      - task: loop_and_echo_var
        vars:
          ECHO_VAR:
            ref: ".EMPTY_LIST_VAR"

  test3:
    cmds:
      - echo "EMPTY_STR_VAR"
      - task: loop_and_echo_var
        vars:
          ECHO_VAR:
            ref: ".EMPTY_STR_VAR"

  test4:
    cmds:
      - echo "NULL_VAR"
      - task: loop_and_echo_var
        vars:
          ECHO_VAR:
            ref: ".NULL_VAR"

With task v3.39.0, I get the following output for each task:

> task -t bug-repro-tasks.yaml test1
task: [test1] echo "UNDEFINED_VAR"
UNDEFINED_VAR
> task -t bug-repro-tasks.yaml test2
task: [test2] echo "EMPTY_LIST_VAR"
EMPTY_LIST_VAR
> task -t bug-repro-tasks.yaml test3
task: [test3] echo "EMPTY_STR_VAR"
EMPTY_STR_VAR
task: Failed to run task "test3": template: :1:8: executing "" at <.ECHO_VAR>: range can't iterate over
> task -t bug-repro-tasks.yaml test4
task: [test4] echo "NULL_VAR"
NULL_VAR

With task v3.40.0, I get the following output for each task:

> task -t bug-repro-tasks.yaml test1
task: [test1] echo "UNDEFINED_VAR"
UNDEFINED_VAR
task: Failed to run task "test1": template: :1:8: executing "" at <.ECHO_VAR>: range can't iterate over
> task -t bug-repro-tasks.yaml test2
task: [test2] echo "EMPTY_LIST_VAR"
EMPTY_LIST_VAR
> task -t bug-repro-tasks.yaml test3
task: [test3] echo "EMPTY_STR_VAR"
EMPTY_STR_VAR
task: Failed to run task "test3": template: :1:8: executing "" at <.ECHO_VAR>: range can't iterate over
> task -t bug-repro-tasks.yaml test4
task: [test4] echo "NULL_VAR"
NULL_VAR
task: Failed to run task "test4": template: :1:8: executing "" at <.ECHO_VAR>: range can't iterate over
  • Task version: 3.40.0
  • Operating system: Ubuntu 22.04
  • Experiments enabled: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs triage Waiting to be triaged by a maintainer.
Projects
None yet
Development

No branches or pull requests

2 participants