Skip to content

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

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

Closed
kirkrodrigues opened this issue Nov 7, 2024 · 1 comment · Fixed by #2144
Closed

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

kirkrodrigues opened this issue Nov 7, 2024 · 1 comment · Fixed by #2144
Labels
area: variables Changes related to variables.

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
@pd93
Copy link
Member

pd93 commented Mar 30, 2025

@kirkrodrigues Thanks for the report and sorry it took a while to get to this. I can confirm this is a bug introduced by #1904. Will be fixed in the next release.

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.

3 participants