[BUG] stdin_raw_newlines is broken in cmdmod #62501
Labels
Bug
broken, incorrect, or confusing behavior
bytes-vs-strings
py2 vs py3 bytes vs strings encode/decode errors
needs-triage
Description
stdin_raw_newlines is broken in cmdmod. stdin is converted to string in _run() (it actually seems to come as string even if the original param in the job published is bytes). salt.utils.timed_subprocess.TimedProc converts it to bytes (https://github.com/saltstack/salt/blob/master/salt/utils/timed_subprocess.py#L36) but not if stdin_raw_newlines=True - then it's left intact and stays str, which causes "memoryview: a bytes-like object is required, not 'str'" exception.
Setup
Anything you like.
Steps to Reproduce the behavior
salt -L anylinuxhost cmd.run_all cmd=cat stdin=abc stdin_raw_newlines=True
compare with
salt -L anyhost cmd.run_all cmd=cat stdin=abc stdin_raw_newlines=False
Expected behavior
Command executes fine. Instead you'll get an error:
Passed invalid arguments to cmd.run: memoryview: a bytes-like object is required, not 'str'
(mind you that "Passed invalid arguments to cmd.run" is nicely misleading there).
Screenshots
N/A
Versions Report
Checked on 3000 but based on the source code it affects all Py3 versions.
The text was updated successfully, but these errors were encountered: