saltstack / saltstack/salt

Saltclass: broken list expansion

Open
#50,262 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

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}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in salt/utils/saltclass.py, especially expand_variables and find_and_process_re, using the reported salt-ssh example.com pillar.items command to reproduce the failure. Trace how the groups list is expanded through the users entry. Done means the Saltclass example expands the list successfully without the replace() argument type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.