Error passing Pillar data to slack engine
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description of Issue
Unable to pass Pillar data to !state.apply command.
For eg. ! state.apply pillar=‘{“editPackage”: “vim”}’ target=*
It throws error in salt master log.
It is similar like #39783
Setup
/etc/salt/master:
file_roots:
base:
- /opt/salt/base
pillar_roots:
base:
- /opt/pillar/base
log_file: /var/log/salt/master
log_level: debug
engines_dirs:
- /opt/engines
engines:
- slack:
token: 'TOKEN VALUE'
control: True
fire_all: false
groups_pillar_name: 'slack_engine:groups_pillar'
groups:
default:
users:
- '*'
commands:
- test.ping
- state.apply
- grains.ls
- cmd.run
- list_jobs
- list_commands
aliases:
list_jobs:
cmd: jobs.list_jobs
list_commands:
cmd: 'pillar.get salt:engines:slack:valid_commands target=* tgt_type=glob'
ping_all:
cmd: test.ping target='*'
default_target:
target: <MASTER MINION ID>
tgt_type: list
/opt/salt/base/top.sls:
base:
'*':
- package
/opt/salt/base/package.sls:
editpackage:
pkg.installed:
- name: {{ pillar['editPackage'] }}
Steps to Reproduce Issue
Command executed in slackbot:
! state.apply pillar=‘{“editPackage”: “vim”}’ target=*
It shows cmdline in master log:
u'cmdline': [u'state.apply', u'pillar=\u2018{\u201ceditPackage\u201d:', u'\u201cvim\u201d}\u2019']
and throw below errors in /var/log/salt/master:
[CRITICAL][30693] Engine 'slack' could not be started!
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/engines/__init__.py", line 132, in run
self.engine[self.fun](**kwargs)
File "/opt/engines/slack.py", line 849, in start
raise Exception('{}'.format(traceback.format_exc()))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 671: ordinal not in range(128)
Versions Report
[root@ip-172-31-13-97 ~]# salt --versions-report
Salt Version:
Salt: 2019.2.2
Dependency Versions:
cffi: 1.6.0
cherrypy: unknown
dateutil: 2.6.0
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.31.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: 2.14
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.16 (default, Sep 13 2019, 20:28:21)
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:
locale: UTF-8
machine: x86_64
release: 4.14.152-127.182.amzn2.x86_64
system: Linux
version: Not Installed
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with salt/engines/init.py around line 132 and the Slack engine's start function around /opt/engines/slack.py line 849. Reproduce the command with the quoted pillar data and inspect how the cmdline is parsed and decoded. Done means the pillar argument reaches state.apply without the UnicodeDecodeError and the engine remains running.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, cli, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100