saltstack / saltstack/salt

state.low: KeyError: '__id__'

Open
#45,682 10 comments 0 reactions 1 assignee View on GitHub

@MKLeb is already working on this.

Since Aug 31, 2023.

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

Description

Description of Issue/Question

state.low expects an explicit __id__.

Setup

CentOS 7; salt installed with bootstrap script.

Steps to Reproduce Issue

The documentation of state.low suggests the following should work:

[root@salt salt]# salt salt\* state.low '{"state": "file", "fun": "exists", "name": "/etc/fstab"}'
salt.localdomain:
    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python2.7/site-packages/salt/minion.py", line 1470, in _thread_return
        return_data = executor.execute()
      File "/usr/lib/python2.7/site-packages/salt/executors/direct_call.py", line 28, in execute
        return self.func(*self.args, **self.kwargs)
      File "/usr/lib/python2.7/site-packages/salt/modules/state.py", line 312, in low
        ret = st_.call(data)
      File "/usr/lib/python2.7/site-packages/salt/state.py", line 1901, in call
        ret['__id__'] = low['__id__']
    KeyError: '__id__'
[root@salt salt]#

However it does not because no explicit __id__ is added. The state compiler explicitly references this key since https://github.com/saltstack/salt/pull/26780.

So either the documentation needs to be updated to reflect the need to explicitly pass __id__, or State.call() needs to handle it being absent.

Also, tests for state.low have not caught this for some reason.

Versions Report
Salt Version:
           Salt: 2017.7.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.5 (default, Aug  4 2017, 00:39:18)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.4.1708 Core
         locale: ANSI_X3.4-1968
        machine: x86_64
        release: 3.10.0-693.11.6.el7.x86_64
         system: Linux
        version: CentOS Linux 7.4.1708 Core

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.