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

Fix a KeyError if group is provided but not user in cmd states #33538

Merged
merged 1 commit into from
May 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions salt/states/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def wait(name,
'Replace them with runas. '
'These arguments will be removed in Salt Oxygen.'
)
if kwargs['user'] is not None and runas is None:
if 'user' in kwargs and kwargs['user'] is not None and runas is None:
runas = kwargs.pop('user')

# Ignoring our arguments is intentional.
Expand Down Expand Up @@ -622,7 +622,7 @@ def wait_script(name,
'Replace them with runas. '
'These arguments will be removed in Salt Oxygen.'
)
if kwargs['user'] is not None and runas is None:
if 'user' in kwargs and kwargs['user'] is not None and runas is None:
runas = kwargs.pop('user')

# Ignoring our arguments is intentional.
Expand Down Expand Up @@ -805,7 +805,7 @@ def run(name,
'Replace them with runas. '
'These arguments will be removed in Salt Oxygen.'
)
if kwargs['user'] is not None and runas is None:
if 'user' in kwargs and kwargs['user'] is not None and runas is None:
runas = kwargs.pop('user')

cmd_kwargs = {'cwd': cwd,
Expand Down Expand Up @@ -1041,7 +1041,7 @@ def script(name,
'Replace them with runas. '
'These arguments will be removed in Salt Oxygen.'
)
if kwargs['user'] is not None and runas is None:
if 'user' in kwargs and kwargs['user'] is not None and runas is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just write if kwargs.get('user') and runas is None here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering that, but wasn't sure if there was some special case behavior if you provide False or an empty string that needs to be preserved. I'd be happy to change it to that if you think it's OK.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just a thought. I can't think of one offhand, since I'd expect strings to be the only case we operate on. I'm fine either way. Just let me know.

runas = kwargs.pop('user')

cmd_kwargs = copy.deepcopy(kwargs)
Expand Down