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] stdin_raw_newlines is broken in cmdmod #62501

Open
szjur opened this issue Aug 22, 2022 · 0 comments
Open

[BUG] stdin_raw_newlines is broken in cmdmod #62501

szjur opened this issue Aug 22, 2022 · 0 comments
Labels
Bug broken, incorrect, or confusing behavior bytes-vs-strings py2 vs py3 bytes vs strings encode/decode errors needs-triage

Comments

@szjur
Copy link

szjur commented Aug 22, 2022

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.

@szjur szjur added Bug broken, incorrect, or confusing behavior needs-triage labels Aug 22, 2022
@OrangeDog OrangeDog added the bytes-vs-strings py2 vs py3 bytes vs strings encode/decode errors label Aug 22, 2022
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 bytes-vs-strings py2 vs py3 bytes vs strings encode/decode errors needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants