Skip to content

Saltclass: broken list expansion #50262

Description

@max-arnold

Description of Issue/Question

This used to work in 2018.3.x:

pillars:
  groups:
    - group1
    - group2
  users:
    user1:
      groups: ${groups}

It seems that #47799 broke list expansions. The example above fails on Fluorine with the following exception:

% salt-ssh example.com pillar.items

[ERROR   ] Exception caught loading ext_pillar 'saltclass':
  File "/Users/user/salt/repos/saltstack-repo/salt/pillar/__init__.py", line 951, in ext_pillar
    key)
  File "/Users/user/salt/repos/saltstack-repo/salt/pillar/__init__.py", line 879, in _external_pillar_data
    *val)
  File "/Users/user/salt/repos/saltstack-repo/salt/pillar/saltclass.py", line 64, in ext_pillar
    return sc.get_pillars(minion_id, salt_data)
  File "/Users/user/salt/repos/saltstack-repo/salt/utils/saltclass.py", line 316, in get_pillars
    pillars_dict_expanded = expand_variables(pillars_dict['pillars'], {}, [])
  File "/Users/user/salt/repos/saltstack-repo/salt/utils/saltclass.py", line 176, in expand_variables
    expand_variables(v, b, expanded, path + [six.text_type(k)])
  File "/Users/user/salt/repos/saltstack-repo/salt/utils/saltclass.py", line 176, in expand_variables
    expand_variables(v, b, expanded, path + [six.text_type(k)])
  File "/Users/user/salt/repos/saltstack-repo/salt/utils/saltclass.py", line 186, in expand_variables
    b = find_and_process_re(v, v, k, b, expanded)
  File "/Users/user/salt/repos/saltstack-repo/salt/utils/saltclass.py", line 158, in find_and_process_re
    v_new = v.replace(re_str, v_expanded)

[CRITICAL] Pillar render error: Failed to load ext_pillar saltclass: replace() argument 2 must be str, not list
example.com:
    ----------
    _errors:
        - Failed to load ext_pillar saltclass: replace() argument 2 must be str, not list
    groups:
        - group1
        - group2
    users:
        ----------
        user1:
            ----------
            groups:
                ${groups}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions