Skip to content

Erroneous “enum reference must resolve to a list” #3020

Description

@RemiBardon

Description

Given the example Taskfile, when I:

task foo FOO=bar

then I get:

enum reference ".LIST" must resolve to a list

It usually works in other places, I don’t get why it doesn’t work here.

My use case is: allowing a set of possible values based on the result of a ls (i.e. “choosing a file”, more or less).

Version

3.52.0

Operating system

macOS 15.7.7 (24G720)

Experiments Enabled

No response

Example Taskfile

version: 3

vars:
  LIST_STR: { sh: printf '%s\n' aaa bbb ccc }
  LIST: { ref: splitLines .LIST_STR }

tasks:
  foo:
    requires:
      vars:
        - name: FOO
          enum: { ref: .LIST }

Activity

  1. trulede commented on Sep 7, 2026

    @trulede
    Contributor

    From google AI, this suggestion, it seems correct so give it a try.

    version: '3'
    
    vars:
      LIST_STR: { sh: printf '%s\n' aaa bbb ccc }
      LIST: '{{splitLines .LIST_STR}}'
    
    tasks:
      foo:
        requires:
          vars:
            - name: FOO
              enum:
                ref: LIST
        cmds:
          - echo "You chose {{.FOO}}"
    
    
  2. added theissue type on Sep 7, 2026
  3. RemiBardon commented on Sep 7, 2026

    @RemiBardon
    Author
    $ task foo FOO=bar
    template: resolver:1: function "LIST" not defined
    

    I’m sorry but did you even try it?

  4. RemiBardon commented on Sep 7, 2026

    @RemiBardon
    Author

    Even with ref: .LIST it goes back to enum reference ".LIST" must resolve to a list… I mean I know I’ve written a correct Taskfile, it’s just a bug I wanted to notify.

    I’m sorry but I’m tired of AI just hallucinating solutions… it just doesn’t work.

  5. trulede commented on Sep 7, 2026

    @trulede
    Contributor

    No, I did not try it. AI is going to be more responsive for figuring this out ... its unlikely that this is going to be a bug. Not impossible, but unlikely.

    You might try to locate LIST var to the task. Is possible that it tries to resolve LIST_STR before the sh is evaluated, relocating would address that.

    See the documentation for examples (which I assume work), notice the location of the 'sh' variable (global) and enum variable (task).
    https://taskfile.dev/docs/guide#using-variable-references-for-enum-values

  6. RemiBardon commented on Sep 7, 2026

    @RemiBardon
    Author

    What do you mean by “AI is going to be more responsive for figuring this out”?

    Also, this —taken from the docs (link you shared)— works:

    version: '3'
    
    vars:
      AVAILABLE_SERVICES:
        sh: ls services/
    
    tasks:
      deploy:
        requires:
          vars:
            - name: SERVICE
              enum:
                ref: .AVAILABLE_SERVICES | splitLines | compact
        cmds:
          - echo "Deploying {{.SERVICE}}"
    $ mkdir services
    $ touch services/foo
    $ task deploy SERVICE=foo
    task: [deploy] echo "Deploying foo"
    Deploying foo
    $ task deploy SERVICE=bar
    task: Task "deploy" cancelled because it is missing required variables:
      - SERVICE has an invalid value : 'bar' (allowed values : [foo])
    

    I don’t see a meaningful difference from my example (which doesn’t work):

    version: 3
    
    vars:
      LIST_STR:
        sh: printf '%s\n' aaa bbb ccc
    
    tasks:
      foo:
        requires:
          vars:
            - name: FOO
              enum:
                ref: splitLines .LIST_STR

    (By the way I am using ls in my code; printf here was to make line separation explicit)

  7. RemiBardon commented on Sep 7, 2026

    @RemiBardon
    Author
    version: '3'
    
    vars:
      AVAILABLE_SERVICES:
        sh: ls services/
    
    tasks:
      deploy:
        requires:
          vars:
            - name: SERVICE
              enum:
    -           ref: .AVAILABLE_SERVICES | splitLines | compact
    +           ref: .AVAILABLE_SERVICES | splitLines
        cmds:
          - echo "Deploying {{.SERVICE}}"

    This is enough to make the docs example fail (enum reference ".AVAILABLE_SERVICES | splitLines" must resolve to a list). I’m sorry but I call this a bug. compact is just supposed to remove empty strings from the slice (https://sprig.taskfile.dev/lists.html#compact-mustcompact).

  8. pd93 commented on Sep 7, 2026

    @pd93
    Member

    @RemiBardon Please update your version of Task to the latest.

    > task --version
    3.52.0
    > task -d ./tmp/3020 foo FOO=bar
    enum reference ".LIST" must resolve to a list
    > task --version
    3.53.1
    > task -d ./tmp/3020 foo FOO=bar
    task: Task "foo" cancelled because it is missing required variables:
      - FOO has an invalid value : 'bar' (allowed values : [aaa bbb ccc])
  9. RemiBardon commented on Sep 7, 2026

    @RemiBardon
    Author

    Oh! That’s nice :) Hadn’t seen the fix being mentioned in the 3.53.1 release (thought I had a recent-enough version)

  10. trulede commented on Sep 7, 2026

    @trulede
    Contributor

    What do you mean by “AI is going to be more responsive for figuring this out”?

    I mean, the AI has got spare time to help you. And its pretty good, even if you have to tell it "no, please try again, this time an example which actually works".

    I have spent the whole day closing PR's submitted to the Task project which were written by AI which are poor quality.

  11. RemiBardon commented on Sep 7, 2026

    @RemiBardon
    Author

    Well you have my full support then because it must be awful 😔 Sorry for being triggered by you sending slop at me. In addition to wasting your time, all this slop you face ends up undermining human-to-human conversations… what a world.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for support.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions