Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Key Error Microsoft #61860

Closed
jtraub91 opened this issue Mar 26, 2022 · 1 comment · Fixed by #62584
Closed

[BUG] Key Error Microsoft #61860

jtraub91 opened this issue Mar 26, 2022 · 1 comment · Fixed by #62584
Assignees
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE lgpo Windows

Comments

@jtraub91
Copy link
Contributor

Description
When applying Microsoft Windows policies with lgpo.set sometimes a KeyError will occur.

Ex:

[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\state.py", line 2154, in call
    *cdata["args"], **cdata["kwargs"]
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\loader.py", line 2106, in wrapper
    return f(*args, **kwargs)
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\states\win_lgpo.py", line 410, in set_
    return_value_only=True,
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\modules\win_lgpo.py", line 9463, in get_policy
    hierarchical_return=hierarchical_return,
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\modules\win_lgpo.py", line 9282, in _get_policy_adm_setting
    for path_needed in unpathed_dict[policy_namespace]:
KeyError: 'Microsoft.Policies.UEV'

See below for the example state which caused this error.

Setup
Install salt-minion on a Windows box

Example state:
Calculator.sls

Calculator:
  lgpo.set:
  - name: Calculator
  - setting: Enabled
  - policy_class: Machine

Steps to Reproduce the behavior

C:\Windows\system32>salt-call --local state.sls Calculator test=True
[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\state.py", line 2154, in call
    *cdata["args"], **cdata["kwargs"]
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\loader.py", line 2106, in wrapper
    return f(*args, **kwargs)
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\states\win_lgpo.py", line 410, in set_
    return_value_only=True,
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\modules\win_lgpo.py", line 9463, in get_policy
    hierarchical_return=hierarchical_return,
  File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\modules\win_lgpo.py", line 9282, in _get_policy_adm_setting
    for path_needed in unpathed_dict[policy_namespace]:
KeyError: 'Microsoft.Policies.UEV'

local:
----------
          ID: Calculator
    Function: lgpo.set
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\state.py", line 2154, in call
                  *cdata["args"], **cdata["kwargs"]
                File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\loader.py", line 2106, in wrapper
                  return f(*args, **kwargs)
                File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\states\win_lgpo.py", line 410, in set_
                  return_value_only=True,
                File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\modules\win_lgpo.py", line 9463, in get_policy
                  hierarchical_return=hierarchical_return,
                File "c:\salt\bin\lib\site-packages\salt-3002.7-py3.7.egg\salt\modules\win_lgpo.py", line 9282, in _get_policy_adm_setting
                  for path_needed in unpathed_dict[policy_namespace]:
              KeyError: 'Microsoft.Policies.UEV'
     Started: 01:24:56.454565
    Duration: 968.75 ms
     Changes:

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time: 968.750 ms

Versions Report

C:\Windows\system32>salt-call --versions-report
Salt Version:
          Salt: 3002.7

Dependency Versions:
          cffi: 1.12.2
      cherrypy: 17.4.1
      dateutil: 2.8.0
     docker-py: Not Installed
         gitdb: 2.0.5
     gitpython: 2.1.10
        Jinja2: 2.10.1
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: 1.0.7
       msgpack: 1.0.0
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.19
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: Not Installed
        Python: 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
  python-gnupg: 0.4.4
        PyYAML: 5.3.1
         PyZMQ: 18.0.1
         smmap: 2.0.5
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.1

System Versions:
          dist:
        locale: cp1252
       machine: AMD64
       release: 10
        system: Windows
       version: 10 10.0.19041 SP0
@jtraub91 jtraub91 added Bug broken, incorrect, or confusing behavior needs-triage labels Mar 26, 2022
@twangboy twangboy self-assigned this May 5, 2022
@twangboy twangboy added Confirmed Salt engineer has confirmed bug/feature - often including a MCVE and removed needs-triage labels May 5, 2022
@twangboy twangboy added this to the Sulphur v3006.0 milestone May 5, 2022
@twangboy
Copy link
Contributor

twangboy commented Sep 1, 2022

The above PR should address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE lgpo Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants