# Buggy code
def _get_user_info(user=None):
    """
    Wrapper for user.info Salt function
    """
    if not user:
        # Get user Salt runnining as
        user = __salt__["config.option"]("user")

    userinfo = __salt__["user.info"](user)

    if not userinfo:
        if user == "salt":
            # Special case with `salt` user:
            # if it doesn't exist then fall back to user Salt running as
            userinfo = _get_user_info()
        else:
            raise SaltInvocationError("User {0} does not exist".format(user))

    return userinfo


# Traceback (ValueError)
[root@master1 salt]# salt-call gpg.encrypt text='Hello there.  How are you?'
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
ValueError: No recipients specified with asymmetric encryption
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
load_entry_point('salt==3000.1', 'console_scripts', 'salt-call')()
File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 445, in salt_call
client.run()
File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 57, in run
caller.run()
File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 119, in run
ret = self.call()
File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 218, in call
ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
File "/usr/lib/python2.7/site-packages/salt/executors/direct_call.py", line 12, in execute
return func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/modules/gpg.py", line 1191, in encrypt
result = gpg.encrypt(text, recipients, passphrase=gpg_passphrase)
File "/usr/lib/python2.7/site-packages/gnupg.py", line 1506, in encrypt
result = self.encrypt_file(data, recipients, **kwargs)
File "/usr/lib/python2.7/site-packages/gnupg.py", line 1440, in encrypt_file
raise ValueError('No recipients specified with asymmetric '
ValueError: No recipients specified with asymmetric encryption
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
load_entry_point('salt==3000.1', 'console_scripts', 'salt-call')()
File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 445, in salt_call
client.run()
File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 57, in run
caller.run()
File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 119, in run
ret = self.call()
File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 218, in call
ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
File "/usr/lib/python2.7/site-packages/salt/executors/direct_call.py", line 12, in execute
return func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/modules/gpg.py", line 1191, in encrypt
result = gpg.encrypt(text, recipients, passphrase=gpg_passphrase)
File "/usr/lib/python2.7/site-packages/gnupg.py", line 1506, in encrypt
result = self.encrypt_file(data, recipients, **kwargs)
File "/usr/lib/python2.7/site-packages/gnupg.py", line 1440, in encrypt_file
raise ValueError('No recipients specified with asymmetric '
ValueError: No recipients specified with asymmetric encryption

# Fixed code
def _get_user_info(user=None):
    """
    Wrapper for user.info Salt function
    """
    if not user:
        # Get user Salt runnining as
        user = __salt__["config.option"]("user")

    userinfo = __salt__["user.info"](user)

    if not userinfo:
        if user == "salt":
            # Special case with `salt` user:
            # if it doesn't exist then fall back to user Salt running as
            userinfo = _get_user_info()
        else:
            raise SaltInvocationError("User {} does not exist".format(user))

    return userinfo