Skip to content

Template function breaks the "requires" feature #1950

@NorbertHauriel

Description

@NorbertHauriel

This could be the exact same, or similar issue as #1557, but there is no reproduction happening there, so I decided to make a new issue, because I found a way to reproduce the "requires" breakage. The required variable is not enforced in the below example.

Expected: "task: Task "default" cancelled because it is missing required variables: MY_VAR"
Result: "template: :1:28: executing "" at <" ">: invalid value; expected string"
Taskfile:

version: 3
tasks:
  default:
    requires:
      vars: [MY_VAR]
    cmd: |
      {{range .MY_VAR | splitList " " }}
      {{end}}

When not using the template function, the required variable feature works as expected.
Result: "task: Task "default" cancelled because it is missing required variables: MY_VAR"

version: 3
tasks:
  default:
    requires:
      vars: [MY_VAR]
    cmd: |
      {{range .MY_VAR }}
      {{end}}
  • Task version: v3.40.0
  • Operating system: Linux, macOS
  • Experiments enabled: no

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions