# Type 'GroupTuple' is unsupported in variable storage

**URL:** <https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513>\
**Category:** Get Help\
**Tags:** jinja2\
**Created:** [September 18, 2025, 4:33pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513 "2025-09-18T16:33:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [September 18, 2025, 4:33pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/1 "2025-09-18T16:33:49Z")

</div>

Given the list

```yaml
data:
  - {group: devel, team: dev_1, users: [alice, bob]}
  - {group: devel, team: dev_2, users: [charlie, david]}
  - {group: qa, team: qa_1, users: [mallory, ted]}

```

The Jinja filter [groupby](https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.groupby) works as expected. The below debug task

```yaml
    - debug:
        msg: "{{ data | groupby('group') }}"

```

however, shows this warning

```yaml
TASK [debug] ********************************************************************************************************
[WARNING]: Type 'GroupTuple' is unsupported in variable storage, converting to 'list'.
Origin: /export/scratch/sandbox/tmp1/test-187/pb6.yml:13:14

11
12 - debug:
13 msg: "{{ data | groupby('group') }}"
                ^ column 14

ok: [localhost] => 
    msg:
    - - devel
        - - group: devel
                team: dev_1
                users:
                - alice
                - bob
            - group: devel
                team: dev_2
                users:
                - charlie
                - david
    - - qa
        - - group: qa
                team: qa_1
                users:
                - mallory
                - ted

```

Explicit conversion doesn’t help

```yaml
    - debug:                                                                                                         
        msg: "{{ data | groupby('group') | list }}"

```

I don’t understand. The below debug

```yaml
    - debug:
        msg: |
          {{ data | type_debug }}
          {{ result | type_debug }}
          {{ result }}
      vars:
        result: "{{ data | groupby('group') }}"

```

shows no warnings. But, I see the warning again if the _result_ is used in a loop

```yaml
    - debug:
        var: item
      loop: "{{ result }}"
      vars:
        result: "{{ data | groupby('group') }}"

```

Is this a bug?

---

<div class="post-metadata">

**Author:** ![Lyle\_McKarns](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lyle_mckarns/32/8142_2.png) [@Lyle\_McKarns](https://forum.ansible.com/u/Lyle_McKarns)\
**Post date:** [September 18, 2025, 5:31pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/2 "2025-09-18T17:31:37Z")

</div>

The first thing I’d try is to use a key name other than “group” since that _could be_ a reserved keyword.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 18, 2025, 5:53pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/3 "2025-09-18T17:53:49Z")

</div>

> [@vbotka](#):
>
> ```auto
> - debug:
> msg: "{{ data | groupby('group') }}"
> 
> ```

Update this to:

```auto
    - debug:
        msg: "{{ data | groupby('group')|map('list') }}"

```

That is what is happening under the hood anyway, when the `GroupTuple` is found. This basically requires an explicit action, or that is what the warning is wanting you to do, because this is a “lossy” operation, which loses information in the “namedtuple” that jinja2 is returning.

The reason for this is that there is no standard JSON serialization for a namedtuple, it requires making a decision about this, and in this case, it’s probably ok for your use to just explicitly convert the inner items to a list.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [September 18, 2025, 9:01pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/4 "2025-09-18T21:01:17Z")

</div>

Thank you. Do I have to explicitly convert all such filters to eliminate these particular warnings? Is the user now responsible for handling this?

This situation is weird. This debug

```yaml
    - debug:
        msg: |
          {{ result }}
      vars:
        result: "{{ data | groupby('group') }}"

```

converts the tuples to lists and shows the warning

```yaml
TASK [debug] ********************************************************************************************************
[WARNING]: Type 'GroupTuple' is unsupported in variable storage, converting to 'list'.
Origin: /export/scratch/sandbox/tmp1/test-187/pb8.yml:23:14

21
22 - debug:
23 msg: |
                ^ column 14

ok: [localhost] => 
    msg:
    - - devel
        - - group: devel
                team: dev_1
                users:
                - alice
                - bob
            - group: devel
                team: dev_2
                users:
                - charlie
                - david
    - - qa
        - - group: qa
                team: qa_1
                users:
                - mallory
                - ted

```

But, adding a trivial line

```yaml
    - debug:
        msg: |
          {{ inventory_hostname }}
          {{ result }}
      vars:
        result: "{{ data | groupby('group') }}"

```

makes the block happy with GroupTuple

```yaml
TASK [debug] ********************************************************************************************************
ok: [localhost] => 
    msg: |-
        localhost
        [('devel', [{'group': 'devel', 'team': 'dev_1', 'users': ['alice', 'bob']}, {'group': 'devel', 'team': 'dev_2', 'users': ['charlie', 'david']}]), ('qa', [{'group': 'qa', 'team': 'qa_1', 'users': ['mallory', 'ted']}])]

```

Such blocks must be identified in 2.19 porting. Are there any other surprises next to _groupby_?

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [September 19, 2025, 8:41am UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/5 "2025-09-19T08:41:06Z")

</div>

> [@Lyle\_McKarns](#):
>
> use a key name other than “group

You probably refer to [Referencing key-value dictionary variables](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#referencing-key-value-dictionary-variables). This is not the case here. JFYI, [YAML places no restrictions on the type of keys](https://yaml.org/spec/1.2.2/#3211-nodes).

---

<div class="post-metadata">

**Author:** ![Lyle\_McKarns](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lyle_mckarns/32/8142_2.png) [@Lyle\_McKarns](https://forum.ansible.com/u/Lyle_McKarns)\
**Post date:** [September 19, 2025, 2:34pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/6 "2025-09-19T14:34:06Z")

</div>

Thanks. It was an off the cuff “first thing I thought of” hit to rule things out. Glad you found the right answer.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [September 22, 2025, 7:21pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/7 "2025-09-22T19:21:33Z")

</div>

> [@vbotka](#):
>
> Are there any other surprises next to _groupby_?

Yes, there are. The below play

```yaml
- hosts: foo

  tasks:

    - command: zpool status
      register: out

    - debug:
        var: pools
      vars:
        status: "{{ out.stdout | community.general.jc('zpool-status') }}"
        pools: "{{ dict(status | community.general.json_query('[].[pool, config[].name]')) }}"

```

gives, for example

```yaml
    pools:
        iocage:
        - iocage
        - ada2
        - ada3
        zroot:
        - zroot
        - ada0p4
        - ada1p4

```

However, _ansible-lint_ complains about

```yaml
pools: "{{ dict(status | community.general.json_query('[].[pool, config[].name]')) }}"

```

> jinja[invalid]: Error rendering template: ‘NoneType’ object is not iterable

Mapping the items from the _json\_query_ output list to _list_ makes the lint error disappear

```yaml
pools: "{{ dict(status | community.general.json_query('[].[pool, config[].name]') | map('list')) }}"

```

I have to repeat my questions:

Is this a bug?

Do I have to explicitly convert all such filters to eliminate these particular warnings (and errors)?

Is the user now responsible for handling this?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 22, 2025, 7:44pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/8 "2025-09-22T19:44:14Z")

</div>

There isn’t a single answer. The `groupby` filter is coming from upstream jinja2, and `json_query` is in `community.general`.

We don’t have knowledge of every python type returned by every filter out there. It’s dependent on the filter, and the reason there is a warning, is to help try to let you know there is something that needs done.

Unfortuantely we can’t know every situation, and these type of things will have to be handled on a per case basis, and using `list` is only 1 solution, for list type values. Other types may be required elsewhere, and I cannot enumerate where they may happen.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [September 24, 2025, 6:48am UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/9 "2025-09-24T06:48:10Z")

</div>

> [@sivel](#):
>
> We don’t have knowledge of every python type returned by every filter out there … try to let you know there is something that needs done.

For the record (to clarify the solution):

Is this a bug? `No`

Do I have to explicitly convert all such filters to eliminate these particular warnings (and errors)? `Yes`

Is the user now responsible for handling this? `Yes`

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [September 24, 2025, 4:07pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/10 "2025-09-24T16:07:16Z")

</div>

For the case @vbotka cited above, could something be done inside or with `community.general.json_query()` to make `ansible-lint` do the Right Thing™? A lot of people use `json_query`, and fixing a class of linting issues would be far preferable to everyone squashing those linting issues in inconsistent ways…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 24, 2025, 4:08pm UTC](https://forum.ansible.com/t/type-grouptuple-is-unsupported-in-variable-storage/44513/11 "2025-10-24T16:08:06Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
