saltstack / saltstack/salt

serializers.yamlex is doing something weird with its string representation

Open
#47,085 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description of Issue/Question

when using yamlex,

#!yamlex
/srv:
  file.directory:
    - makedirs: True
    - group: root
    - user: root
    - mode: 755

the following fails

mmp-sl-test-1:
----------
          ID: "/srv"
    Function: file.directory
      Result: False
     Comment: Group "root" is not available
     Started: 15:26:39.835190
    Duration: 9.279 ms
     Changes:

if you remove the try guard,

KeyError: 'getgrnam(): name not found: "root"'

it seems to be making the root string not actually root. when evaluating group == 'root' before the getgrnam() it evaluated as true, so it's likely something with utf8 encoding that yamlex is doing.

Salt Version:
           Salt: 2018.3.0-2279-g68546d2

Dependency Versions:
           cffi: 1.11.5
       cherrypy: unknown
       dateutil: 2.6.1
      docker-py: 3.1.4
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.29.0
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.18
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.14 (default, Mar 14 2018, 09:26:40)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 17.0.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.1.6

System Versions:
           dist: redhat 7.3 Maipo
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-514.6.1.el7.x86_64
         system: Linux
        version: Red Hat Enterprise Linux Server 7.3 Maipo```

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 by reproducing the shown Salt 2018.3.0 failure with the provided yamlex state, then trace serializers.yamlex through the value passed to getgrnam(). Compare that value with the literal 'root'; the issue is done when yamlex preserves the expected string representation and the example succeeds without the KeyError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, yaml
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.