gurudesh/pytracebugs huggingface dataset:
# Buggy code
def set_(package, question, type, value, *extra):
    """
    Set answers to debconf questions for a package.

    CLI Example:

    .. code-block:: bash

        salt '*' debconf.set <package> <question> <type> <value> [<value> ...]
    """

    if extra:
        value = " ".join((value,) + tuple(extra))

    fd_, fname = salt.utils.files.mkstemp(prefix="salt-", close_fd=False)

    line = "{0} {1} {2} {3}".format(package, question, type, value)
    os.write(fd_, line)
    os.close(fd_)

    _set_file(fname)

    os.unlink(fname)

    return True


# Traceback (TypeError)
# salt-call -l debug debconf.set testpkg question string value
[...]
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded debconf.set

Passed invalid arguments: a bytes-like object is required, not 'str'.

Usage:

Set answers to debconf questions for a package.

CLI Example:

.. code-block:: bash

salt '*' debconf.set <package> <question> <type> <value> [<value> ...]

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 204, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python3/dist-packages/salt/modules/debconfmod.py", line 130, in set_
os.write(fd_, line)
TypeError: a bytes-like object is required, not 'str'

# Fixed code
def set_(package, question, type, value, *extra):
    """
    Set answers to debconf questions for a package.

    CLI Example:

    .. code-block:: bash

        salt '*' debconf.set <package> <question> <type> <value> [<value> ...]
    """

    if extra:
        value = " ".join((value,) + tuple(extra))

    fd_, fname = salt.utils.files.mkstemp(prefix="salt-", close_fd=False)

    line = "{0} {1} {2} {3}".format(package, question, type, value)
    os.write(fd_, salt.utils.stringutils.to_bytes(line))
    os.close(fd_)

    _set_file(fname)

    os.unlink(fname)

    return True
# Buggy code
def compile_pillar(self):
    """
    Return the pillar data from the master
    """
    load = {
        "id": self.minion_id,
        "grains": self.grains,
        "saltenv": self.opts["environment"],
        "pillarenv": self.opts["pillarenv"],
        "pillar_override": self.pillar_override,
        "ver": "2",
        "cmd": "_pillar",
    }
    if self.ext:
        load["ext"] = self.ext
    ret_pillar = self.channel.crypted_transfer_decode_dictentry(
        load,
        dictkey="pillar",
    )

    if not isinstance(ret_pillar, dict):
        log.error(
            "Got a bad pillar from master, type {0}, expecting dict: {1}".format(
                type(ret_pillar).__name__, ret_pillar
            )
        )
        return {}
    return ret_pillar


# Traceback (UnicodeDecodeError)
[ERROR   ] Unable to manage file: Jinja error: 'ascii' codec can't decode byte 0xe3 in p osition 0: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 366, in render_j inja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exc eption
reraise(exc_type, exc_value, tb)
File "<template>", line 1, in top-level template code
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 0: ordinal not in r ange(128)

; line 1

---
{{ pillar.test }}    <======================

Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 366, in render_j inja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
[...]

# Fixed code
def compile_pillar(self):
    """
    Return the pillar data from the master
    """
    load = {
        "id": self.minion_id,
        "grains": self.grains,
        "saltenv": self.opts["environment"],
        "pillarenv": self.opts["pillarenv"],
        "pillar_override": self.pillar_override,
        "ver": "2",
        "cmd": "_pillar",
    }
    if self.ext:
        load["ext"] = self.ext
    ret_pillar = self.channel.crypted_transfer_decode_dictentry(
        load,
        dictkey="pillar",
    )

    if not isinstance(ret_pillar, dict):
        log.error(
            "Got a bad pillar from master, type {0}, expecting dict: {1}".format(
                type(ret_pillar).__name__, ret_pillar
            )
        )
        return {}
    return decode_recursively(ret_pillar)
# Buggy code
def __virtual__():
    """
    Only works on Windows systems with the _winreg python module
    """
    if not salt.utils.is_windows():
        return (
            False,
            "reg execution module failed to load: "
            "The module will only run on Windows systems",
        )

    if not HAS_WINDOWS_MODULES:
        return (
            False,
            "reg execution module failed to load: "
            "One of the following libraries did not load: "
            + "_winreg, win32gui, win32con, win32api",
        )

    return __virtualname__


# Traceback (CommandExecutionError)
windows_host:
----------
ID: lgpo_test
Function: lgpo.set
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt\state.py", line 1765, in call
**cdata['kwargs'])
File "c:\salt\bin\lib\site-packages\salt\loader.py", line 1705, in wrapper
return f(*args, **kwargs)
File "c:\salt\bin\lib\site-packages\salt\states\win_lgpo.py", line 294, in set_
adml_language=adml_language)
File "c:\salt\bin\lib\site-packages\salt\modules\win_lgpo.py", line 5348, in set_
raise CommandExecutionError(msg.format(regedit))
CommandExecutionError: Error while attempting to set policy Domain controller: Allow server operators to schedule tasks via the registry.  Some changes may not be applied as expected
Started: 15:33:50.693000
Duration: 1578.0 ms
Changes:

Summary for windoze
------------
Succeeded: 0
Failed:    1

# Fixed code
def __virtual__():
    """
    Only works on Windows systems with the PyWin32
    """
    if not salt.utils.is_windows():
        return (
            False,
            "reg execution module failed to load: "
            "The module will only run on Windows systems",
        )

    if not HAS_WINDOWS_MODULES:
        return (
            False,
            "reg execution module failed to load: "
            "One of the following libraries did not load: "
            + "win32gui, win32con, win32api",
        )

    return __virtualname__
# Buggy code
def _key_exists(hive, key, use_32bit_registry=False):
    """
    Check that the key is found in the registry

    :param str hive: The hive to connect to.
    :param str key: The key to check
    :param bool use_32bit_registry: Look in the 32bit portion of the registry

    :return: Returns True if found, False if not found
    :rtype: bool
    """

    if PY2:
        local_hive = _mbcs_to_unicode(hive)
        local_key = _unicode_to_mbcs(key)
    else:
        local_hive = hive
        local_key = key

    registry = Registry()
    hkey = registry.hkeys[local_hive]
    access_mask = registry.registry_32[use_32bit_registry]

    try:
        handle = _winreg.OpenKey(hkey, local_key, 0, access_mask)
        _winreg.CloseKey(handle)
        return True
    except WindowsError:  # pylint: disable=E0602
        return False


# Traceback (CommandExecutionError)
windows_host:
----------
ID: lgpo_test
Function: lgpo.set
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt\state.py", line 1765, in call
**cdata['kwargs'])
File "c:\salt\bin\lib\site-packages\salt\loader.py", line 1705, in wrapper
return f(*args, **kwargs)
File "c:\salt\bin\lib\site-packages\salt\states\win_lgpo.py", line 294, in set_
adml_language=adml_language)
File "c:\salt\bin\lib\site-packages\salt\modules\win_lgpo.py", line 5348, in set_
raise CommandExecutionError(msg.format(regedit))
CommandExecutionError: Error while attempting to set policy Domain controller: Allow server operators to schedule tasks via the registry.  Some changes may not be applied as expected
Started: 15:33:50.693000
Duration: 1578.0 ms
Changes:

Summary for windoze
------------
Succeeded: 0
Failed:    1

# Fixed code
def _key_exists(hive, key, use_32bit_registry=False):
    """
    Check that the key is found in the registry

    :param str hive: The hive to connect to.
    :param str key: The key to check
    :param bool use_32bit_registry: Look in the 32bit portion of the registry

    :return: Returns True if found, False if not found
    :rtype: bool
    """
    local_hive = _to_unicode(hive)
    local_key = _to_unicode(key)

    registry = Registry()
    hkey = registry.hkeys[local_hive]
    access_mask = registry.registry_32[use_32bit_registry]

    try:
        handle = win32api.RegOpenKeyEx(hkey, local_key, 0, access_mask)
        win32api.RegCloseKey(handle)
        return True
    except WindowsError:  # pylint: disable=E0602
        return False
# Buggy code
def broadcast_change():
    """
    Refresh the windows environment.

    Returns (bool): True if successful, otherwise False

    CLI Example:

    .. code-block:: bash

        salt '*' reg.broadcast_change
    """
    # https://msdn.microsoft.com/en-us/library/windows/desktop/ms644952(v=vs.85).aspx
    _, res = SendMessageTimeout(
        HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0, SMTO_ABORTIFHUNG, 5000
    )
    return not bool(res)


# Traceback (CommandExecutionError)
windows_host:
----------
ID: lgpo_test
Function: lgpo.set
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt\state.py", line 1765, in call
**cdata['kwargs'])
File "c:\salt\bin\lib\site-packages\salt\loader.py", line 1705, in wrapper
return f(*args, **kwargs)
File "c:\salt\bin\lib\site-packages\salt\states\win_lgpo.py", line 294, in set_
adml_language=adml_language)
File "c:\salt\bin\lib\site-packages\salt\modules\win_lgpo.py", line 5348, in set_
raise CommandExecutionError(msg.format(regedit))
CommandExecutionError: Error while attempting to set policy Domain controller: Allow server operators to schedule tasks via the registry.  Some changes may not be applied as expected
Started: 15:33:50.693000
Duration: 1578.0 ms
Changes:

Summary for windoze
------------
Succeeded: 0
Failed:    1

# Fixed code
def broadcast_change():
    """
    Refresh the windows environment.

    Returns (bool): True if successful, otherwise False

    CLI Example:

    .. code-block:: bash

        salt '*' reg.broadcast_change
    """
    # https://msdn.microsoft.com/en-us/library/windows/desktop/ms644952(v=vs.85).aspx
    _, res = win32gui.SendMessageTimeout(
        win32con.HWND_BROADCAST,
        win32con.WM_SETTINGCHANGE,
        0,
        0,
        win32con.SMTO_ABORTIFHUNG,
        5000,
    )
    return not bool(res)
# Buggy code
def _subkeys(_key):
    """
    Enumerate keys
    """
    i = 0
    while True:
        try:
            subkey = _winreg.EnumKey(_key, i)
            yield subkey
            i += 1
        except WindowsError:  # pylint: disable=E0602
            break


# Traceback (CommandExecutionError)
windows_host:
----------
ID: lgpo_test
Function: lgpo.set
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt\state.py", line 1765, in call
**cdata['kwargs'])
File "c:\salt\bin\lib\site-packages\salt\loader.py", line 1705, in wrapper
return f(*args, **kwargs)
File "c:\salt\bin\lib\site-packages\salt\states\win_lgpo.py", line 294, in set_
adml_language=adml_language)
File "c:\salt\bin\lib\site-packages\salt\modules\win_lgpo.py", line 5348, in set_
raise CommandExecutionError(msg.format(regedit))
CommandExecutionError: Error while attempting to set policy Domain controller: Allow server operators to schedule tasks via the registry.  Some changes may not be applied as expected
Started: 15:33:50.693000
Duration: 1578.0 ms
Changes:

Summary for windoze
------------
Succeeded: 0
Failed:    1

# Fixed code
def _subkeys(_key):
    """
    Enumerate keys
    """
    i = 0
    while True:
        try:
            subkey = win32api.RegEnumKey(_key, i)
            yield subkey
            i += 1
        except pywintypes.error:  # pylint: disable=E0602
            break
# Buggy code
def _traverse_registry_tree(_hkey, _keypath, _ret, _access_mask):
    """
    Traverse the registry tree i.e. dive into the tree
    """
    _key = _winreg.OpenKey(_hkey, _keypath, 0, _access_mask)
    for subkeyname in _subkeys(_key):
        subkeypath = r"{0}\{1}".format(_keypath, subkeyname)
        _ret = _traverse_registry_tree(_hkey, subkeypath, _ret, access_mask)
        _ret.append("{0}".format(subkeypath))
    return _ret


# Traceback (CommandExecutionError)
windows_host:
----------
ID: lgpo_test
Function: lgpo.set
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt\state.py", line 1765, in call
**cdata['kwargs'])
File "c:\salt\bin\lib\site-packages\salt\loader.py", line 1705, in wrapper
return f(*args, **kwargs)
File "c:\salt\bin\lib\site-packages\salt\states\win_lgpo.py", line 294, in set_
adml_language=adml_language)
File "c:\salt\bin\lib\site-packages\salt\modules\win_lgpo.py", line 5348, in set_
raise CommandExecutionError(msg.format(regedit))
CommandExecutionError: Error while attempting to set policy Domain controller: Allow server operators to schedule tasks via the registry.  Some changes may not be applied as expected
Started: 15:33:50.693000
Duration: 1578.0 ms
Changes:

Summary for windoze
------------
Succeeded: 0
Failed:    1

# Fixed code
def _traverse_registry_tree(_hkey, _keypath, _ret, _access_mask):
    """
    Traverse the registry tree i.e. dive into the tree
    """
    _key = win32api.RegOpenKeyEx(_hkey, _keypath, 0, _access_mask)
    for subkeyname in _subkeys(_key):
        subkeypath = r"{0}\{1}".format(_keypath, subkeyname)
        _ret = _traverse_registry_tree(_hkey, subkeypath, _ret, access_mask)
        _ret.append("{0}".format(subkeypath))
    return _ret
# Buggy code
def to_unicode(s, encoding=None):
    """
    Given str or unicode, return unicode (str for python 3)
    """
    if six.PY3:
        return to_str(s, encoding)
    else:
        if isinstance(s, str):
            return s.decode(encoding or __salt_system_encoding__)
        return unicode(s)  # pylint: disable=incompatible-py3-code


# Traceback (CommandExecutionError)
windows_host:
----------
ID: lgpo_test
Function: lgpo.set
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt\state.py", line 1765, in call
**cdata['kwargs'])
File "c:\salt\bin\lib\site-packages\salt\loader.py", line 1705, in wrapper
return f(*args, **kwargs)
File "c:\salt\bin\lib\site-packages\salt\states\win_lgpo.py", line 294, in set_
adml_language=adml_language)
File "c:\salt\bin\lib\site-packages\salt\modules\win_lgpo.py", line 5348, in set_
raise CommandExecutionError(msg.format(regedit))
CommandExecutionError: Error while attempting to set policy Domain controller: Allow server operators to schedule tasks via the registry.  Some changes may not be applied as expected
Started: 15:33:50.693000
Duration: 1578.0 ms
Changes:

Summary for windoze
------------
Succeeded: 0
Failed:    1

# Fixed code
def to_unicode(s, encoding=None):
    """
    Given str or unicode, return unicode (str for python 3)
    """
    if s is None:
        return s
    if six.PY3:
        return to_str(s, encoding)
    else:
        if isinstance(s, str):
            return s.decode(encoding or __salt_system_encoding__)
        return unicode(s)  # pylint: disable=incompatible-py3-code
# Buggy code
def caller(*args, **kwargs):
    """
    The remote execution function
    """
    argv = [cmd]
    argv.extend([salt.utils.json.dumps(arg) for arg in args])
    argv.extend(
        [
            "{0}={1}".format(
                salt.utils.stringutils.to_str(key), salt.utils.json.dumps(val)
            )
            for key, val in six.iteritems(kwargs)
        ]
    )
    single = salt.client.ssh.Single(
        self.opts,
        argv,
        mods=self.mods,
        wipe=True,
        fsclient=self.fsclient,
        minion_opts=self.minion_opts,
        **self.kwargs,
    )
    stdout, stderr, retcode = single.cmd_block()
    if stderr.count("Permission Denied"):
        return {
            "_error": "Permission Denied",
            "stdout": stdout,
            "stderr": stderr,
            "retcode": retcode,
        }
    try:
        ret = salt.utils.json.loads(stdout, object_hook=salt.utils.data.decode_dict)
        if len(ret) < 2 and "local" in ret:
            ret = ret["local"]
        ret = ret.get("return", {})
    except ValueError:
        ret = {
            "_error": "Failed to return clean data",
            "stderr": stderr,
            "stdout": stdout,
            "retcode": retcode,
        }
    return ret


# Traceback (KeyError)
ssh:
----------
ID: echo
Function: cmd.run
Name: echo 'This is a test!'
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/var/tmp/.root_62a99a_salt/py3/salt/state.py", line 1905, in call
**cdata['kwargs'])
File "/var/tmp/.root_62a99a_salt/py3/salt/loader.py", line 1822, in wrapper
return f(*args, **kwargs)
File "/var/tmp/.root_62a99a_salt/py3/salt/states/cmd.py", line 865, in run
'shell': shell or __grains__['shell'],
File "/var/tmp/.root_62a99a_salt/py3/salt/utils/context.py", line 228, in __getitem__
return self._dict()[key]
KeyError: 'shell'
Started: 19:56:36.251433
Duration: 6.909 ms
Changes:

# Fixed code
def caller(*args, **kwargs):
    """
    The remote execution function
    """
    argv = [cmd]
    argv.extend([salt.utils.json.dumps(arg) for arg in args])
    argv.extend(
        [
            "{0}={1}".format(
                salt.utils.stringutils.to_str(key), salt.utils.json.dumps(val)
            )
            for key, val in six.iteritems(kwargs)
        ]
    )
    single = salt.client.ssh.Single(
        self.opts,
        argv,
        mods=self.mods,
        wipe=True,
        fsclient=self.fsclient,
        minion_opts=self.minion_opts,
        **self.kwargs,
    )
    stdout, stderr, retcode = single.cmd_block()
    if stderr.count("Permission Denied"):
        return {
            "_error": "Permission Denied",
            "stdout": stdout,
            "stderr": stderr,
            "retcode": retcode,
        }
    try:
        ret = salt.utils.json.loads(stdout)
        if len(ret) < 2 and "local" in ret:
            ret = ret["local"]
        ret = ret.get("return", {})
    except ValueError:
        ret = {
            "_error": "Failed to return clean data",
            "stderr": stderr,
            "stdout": stdout,
            "retcode": retcode,
        }
    return ret
# Buggy code
def jobber_check(self):
    """
    Iterate over the shell jobbers and return the ones that have finished
    """
    rms = []
    for jid in self.shells.value:
        if isinstance(self.shells.value[jid]["proc"].poll(), int):
            rms.append(jid)
            data = self.shells.value[jid]
            stdout, stderr = data["proc"].communicate()
            ret = salt.utils.json.loads(
                stdout, object_hook=salt.utils.data.encode_dict
            )["local"]
            route = {
                "src": (self.stack.value.local.name, "manor", "jid_ret"),
                "dst": (data["msg"]["route"]["src"][0], None, "remote_cmd"),
            }
            ret["cmd"] = "_return"
            ret["id"] = self.opts.value["id"]
            ret["jid"] = jid
            msg = {"route": route, "load": ret}
            master = self.stack.value.nameRemotes.get(data["msg"]["route"]["src"][0])
            self.stack.value.message(msg, master.uid)
    for rm_ in rms:
        self.shells.value.pop(rm_)


# Traceback (KeyError)
ssh:
----------
ID: echo
Function: cmd.run
Name: echo 'This is a test!'
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/var/tmp/.root_62a99a_salt/py3/salt/state.py", line 1905, in call
**cdata['kwargs'])
File "/var/tmp/.root_62a99a_salt/py3/salt/loader.py", line 1822, in wrapper
return f(*args, **kwargs)
File "/var/tmp/.root_62a99a_salt/py3/salt/states/cmd.py", line 865, in run
'shell': shell or __grains__['shell'],
File "/var/tmp/.root_62a99a_salt/py3/salt/utils/context.py", line 228, in __getitem__
return self._dict()[key]
KeyError: 'shell'
Started: 19:56:36.251433
Duration: 6.909 ms
Changes:

# Fixed code
def jobber_check(self):
    """
    Iterate over the shell jobbers and return the ones that have finished
    """
    rms = []
    for jid in self.shells.value:
        if isinstance(self.shells.value[jid]["proc"].poll(), int):
            rms.append(jid)
            data = self.shells.value[jid]
            stdout, stderr = data["proc"].communicate()
            ret = salt.utils.json.loads(
                stdout, object_hook=salt.utils.data.encode_dict if six.PY2 else None
            )["local"]
            route = {
                "src": (self.stack.value.local.name, "manor", "jid_ret"),
                "dst": (data["msg"]["route"]["src"][0], None, "remote_cmd"),
            }
            ret["cmd"] = "_return"
            ret["id"] = self.opts.value["id"]
            ret["jid"] = jid
            msg = {"route": route, "load": ret}
            master = self.stack.value.nameRemotes.get(data["msg"]["route"]["src"][0])
            self.stack.value.message(msg, master.uid)
    for rm_ in rms:
        self.shells.value.pop(rm_)
# Buggy code
def create(name, profile):
    """
    Create the named vm

    CLI Example:

    .. code-block:: bash

        salt <minion-id> saltcloud.create webserver rackspace_centos_512
    """
    cmd = "salt-cloud --out json -p {0} {1}".format(profile, name)
    out = __salt__["cmd.run_stdout"](cmd, python_shell=False)
    try:
        ret = salt.utils.json.loads(out, object_hook=salt.utils.data.encode_dict)
    except ValueError:
        ret = {}
    return ret


# Traceback (KeyError)
ssh:
----------
ID: echo
Function: cmd.run
Name: echo 'This is a test!'
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/var/tmp/.root_62a99a_salt/py3/salt/state.py", line 1905, in call
**cdata['kwargs'])
File "/var/tmp/.root_62a99a_salt/py3/salt/loader.py", line 1822, in wrapper
return f(*args, **kwargs)
File "/var/tmp/.root_62a99a_salt/py3/salt/states/cmd.py", line 865, in run
'shell': shell or __grains__['shell'],
File "/var/tmp/.root_62a99a_salt/py3/salt/utils/context.py", line 228, in __getitem__
return self._dict()[key]
KeyError: 'shell'
Started: 19:56:36.251433
Duration: 6.909 ms
Changes:

# Fixed code
def create(name, profile):
    """
    Create the named vm

    CLI Example:

    .. code-block:: bash

        salt <minion-id> saltcloud.create webserver rackspace_centos_512
    """
    cmd = "salt-cloud --out json -p {0} {1}".format(profile, name)
    out = __salt__["cmd.run_stdout"](cmd, python_shell=False)
    try:
        ret = salt.utils.json.loads(out)
    except ValueError:
        ret = {}
    return ret
# Buggy code
def find_json(raw):
    """
    Pass in a raw string and load the json when it starts. This allows for a
    string to start with garbage and end with json but be cleanly loaded
    """
    ret = {}
    for ind, _ in enumerate(raw):
        working = "\n".join(raw.splitlines()[ind:])
        try:
            ret = json.loads(
                working, object_hook=salt.utils.data.decode_dict
            )  # future lint: blacklisted-function
        except ValueError:
            continue
        if ret:
            return ret
    if not ret:
        # Not json, raise an error
        raise ValueError


# Traceback (KeyError)
ssh:
----------
ID: echo
Function: cmd.run
Name: echo 'This is a test!'
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/var/tmp/.root_62a99a_salt/py3/salt/state.py", line 1905, in call
**cdata['kwargs'])
File "/var/tmp/.root_62a99a_salt/py3/salt/loader.py", line 1822, in wrapper
return f(*args, **kwargs)
File "/var/tmp/.root_62a99a_salt/py3/salt/states/cmd.py", line 865, in run
'shell': shell or __grains__['shell'],
File "/var/tmp/.root_62a99a_salt/py3/salt/utils/context.py", line 228, in __getitem__
return self._dict()[key]
KeyError: 'shell'
Started: 19:56:36.251433
Duration: 6.909 ms
Changes:

# Fixed code
def find_json(raw):
    """
    Pass in a raw string and load the json when it starts. This allows for a
    string to start with garbage and end with json but be cleanly loaded
    """
    ret = {}
    for ind, _ in enumerate(raw):
        working = "\n".join(raw.splitlines()[ind:])
        try:
            ret = json.loads(working)  # future lint: blacklisted-function
        except ValueError:
            continue
        if ret:
            return ret
    if not ret:
        # Not json, raise an error
        raise ValueError
# Buggy code
def strip_esc_sequence(txt):
    """
    Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings
    from writing their own terminal manipulation commands
    """
    if isinstance(txt, six.string_types):
        return txt.replace("\033", "?")
    else:
        return txt


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/usr/local/bin/salt", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/root/salt/scripts/salt", line 10, in <module>
salt_main()
File "/root/salt/salt/scripts.py", line 480, in salt_main
client.run()
File "/root/salt/salt/cli/salt.py", line 195, in run
self._output_ret(ret_, out, retcode=retcode)
File "/root/salt/salt/cli/salt.py", line 374, in _output_ret
_retcode=retcode)
File "/root/salt/salt/output/__init__.py", line 94, in display_output
display_data = try_printout(data, out, opts, **kwargs)
File "/root/salt/salt/output/__init__.py", line 41, in try_printout
printout = get_printout(out, opts)(data, **kwargs)
File "/root/salt/salt/output/highstate.py", line 146, in output
for host, hostdata in six.iteritems(data)
File "/root/salt/salt/output/highstate.py", line 225, in _format_host
schanged, ctext = _format_changes(ret['changes'], orchestration)
File "/root/salt/salt/output/highstate.py", line 516, in _format_changes
ctext = _nested_changes(changes)
File "/root/salt/salt/output/highstate.py", line 489, in _nested_changes
nested_indent=14)
File "/root/salt/salt/output/__init__.py", line 203, in out_format
return try_printout(data, out, opts, **kwargs)
File "/root/salt/salt/output/__init__.py", line 41, in try_printout
printout = get_printout(out, opts)(data, **kwargs)
File "/root/salt/salt/output/nested.py", line 186, in output
return '\n'.join(nest.display(ret, base_indent, '', []))
File "/root/salt/salt/output/nested.py", line 173, in display
self.display(val, indent + 4, '', out)
File "/root/salt/salt/output/nested.py", line 173, in display
self.display(val, indent + 4, '', out)
File "/root/salt/salt/output/nested.py", line 173, in display
self.display(val, indent + 4, '', out)
File "/root/salt/salt/output/nested.py", line 87, in display
ret = salt.utils.stringutils.to_unicode(ret)
File "/root/salt/salt/utils/stringutils.py", line 110, in to_unicode
return s.decode('utf-8', errors)
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 13-14: invalid continuation byte

# Fixed code
def strip_esc_sequence(txt):
    """
    Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings
    from writing their own terminal manipulation commands
    """
    if isinstance(txt, six.string_types):
        try:
            return txt.replace("\033", "?")
        except UnicodeDecodeError:
            return txt.replace(
                str("\033"), str("?")
            )  # future lint: disable=blacklisted-function
    else:
        return txt
# Buggy code
def output(ret, **kwargs):
    """
    Display ret data
    """
    # Prefer kwargs before opts
    retcode = kwargs.get("_retcode", 0)
    base_indent = kwargs.get("nested_indent", 0) or __opts__.get("nested_indent", 0)
    nest = NestDisplay(retcode=retcode)
    return "\n".join(nest.display(ret, base_indent, "", []))


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/usr/local/bin/salt", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/root/salt/scripts/salt", line 10, in <module>
salt_main()
File "/root/salt/salt/scripts.py", line 480, in salt_main
client.run()
File "/root/salt/salt/cli/salt.py", line 195, in run
self._output_ret(ret_, out, retcode=retcode)
File "/root/salt/salt/cli/salt.py", line 374, in _output_ret
_retcode=retcode)
File "/root/salt/salt/output/__init__.py", line 94, in display_output
display_data = try_printout(data, out, opts, **kwargs)
File "/root/salt/salt/output/__init__.py", line 41, in try_printout
printout = get_printout(out, opts)(data, **kwargs)
File "/root/salt/salt/output/highstate.py", line 146, in output
for host, hostdata in six.iteritems(data)
File "/root/salt/salt/output/highstate.py", line 225, in _format_host
schanged, ctext = _format_changes(ret['changes'], orchestration)
File "/root/salt/salt/output/highstate.py", line 516, in _format_changes
ctext = _nested_changes(changes)
File "/root/salt/salt/output/highstate.py", line 489, in _nested_changes
nested_indent=14)
File "/root/salt/salt/output/__init__.py", line 203, in out_format
return try_printout(data, out, opts, **kwargs)
File "/root/salt/salt/output/__init__.py", line 41, in try_printout
printout = get_printout(out, opts)(data, **kwargs)
File "/root/salt/salt/output/nested.py", line 186, in output
return '\n'.join(nest.display(ret, base_indent, '', []))
File "/root/salt/salt/output/nested.py", line 173, in display
self.display(val, indent + 4, '', out)
File "/root/salt/salt/output/nested.py", line 173, in display
self.display(val, indent + 4, '', out)
File "/root/salt/salt/output/nested.py", line 173, in display
self.display(val, indent + 4, '', out)
File "/root/salt/salt/output/nested.py", line 87, in display
ret = salt.utils.stringutils.to_unicode(ret)
File "/root/salt/salt/utils/stringutils.py", line 110, in to_unicode
return s.decode('utf-8', errors)
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 13-14: invalid continuation byte

# Fixed code
def output(ret, **kwargs):
    """
    Display ret data
    """
    # Prefer kwargs before opts
    retcode = kwargs.get("_retcode", 0)
    base_indent = kwargs.get("nested_indent", 0) or __opts__.get("nested_indent", 0)
    nest = NestDisplay(retcode=retcode)
    lines = nest.display(ret, base_indent, "", [])
    try:
        return "\n".join(lines)
    except UnicodeDecodeError:
        # output contains binary data that can't be decoded
        return str("\n").join(  # future lint: disable=blacklisted-function
            [salt.utils.stringutils.to_str(x) for x in lines]
        )
# Buggy code
def _get_name_map(saltenv="base"):
    """
    Return a reverse map of full pkg names to the names recognized by winrepo.
    """
    u_name_map = {}
    name_map = get_repo_data(saltenv).get("name_map", {})

    if not six.PY2:
        return name_map

    for k in name_map:
        u_name_map[k.decode("utf-8")] = name_map[k]
    return u_name_map


# Traceback (UnicodeEncodeError)
The minion function caused an exception: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt\minion.py", line 1624, in _thread_return
return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
File "c:\salt\bin\lib\site-packages\salt\executors\direct_call.py", line 12, in execute
return func(*args, **kwargs)
File "c:\salt\bin\lib\site-packages\salt\modules\win_pkg.py", line 1142, in install
old = list_pkgs(saltenv=saltenv, refresh=refresh, versions_as_list=True)
File "c:\salt\bin\lib\site-packages\salt\modules\win_pkg.py", line 400, in list_pkgs
name_map = _get_name_map(saltenv)
File "c:\salt\bin\lib\site-packages\salt\modules\win_pkg.py", line 1846, in _get_name_map
u_name_map[k.decode('utf-8')] = name_map[k]
File "c:\salt\bin\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-11: ordinal not in range(128)

# Fixed code
def _get_name_map(saltenv="base"):
    """
    Return a reverse map of full pkg names to the names recognized by winrepo.
    """
    u_name_map = {}
    name_map = get_repo_data(saltenv).get("name_map", {})

    if not six.PY2:
        return name_map

    for k in name_map:
        u_name_map[k] = name_map[k]
    return u_name_map
# Buggy code
def file_list(self, saltenv="base", prefix=""):
    """
    List the files on the master
    """
    load = {"saltenv": saltenv, "prefix": prefix, "cmd": "_file_list"}

    return [sdecode(fn_) for fn_ in self.channel.send(load)]


# Traceback (UnicodeEncodeError)
ID: test1
Function: file.recurse
Name: /root/group2test
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1703, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2807, in recurse
manage_file(dest, src)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2685, in manage_file
**pass_kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1814, in managed
__env__
File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 3490, in source_list
contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-34: ordinal not in range(128)
Started: 20:08:21.608398
Duration: 1467.811 ms
Changes:

# Fixed code
def file_list(self, saltenv="base", prefix=""):
    """
    List the files on the master
    """
    load = {"saltenv": saltenv, "prefix": prefix, "cmd": "_file_list"}
    return (
        salt.utils.data.decode(self.channel.send(load))
        if six.PY2
        else self.channel.send(load)
    )
# Buggy code
def file_list_emptydirs(self, saltenv="base", prefix=""):
    """
    List the empty dirs on the master
    """
    load = {"saltenv": saltenv, "prefix": prefix, "cmd": "_file_list_emptydirs"}
    self.channel.send(load)


# Traceback (UnicodeEncodeError)
ID: test1
Function: file.recurse
Name: /root/group2test
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1703, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2807, in recurse
manage_file(dest, src)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2685, in manage_file
**pass_kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1814, in managed
__env__
File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 3490, in source_list
contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-34: ordinal not in range(128)
Started: 20:08:21.608398
Duration: 1467.811 ms
Changes:

# Fixed code
def file_list_emptydirs(self, saltenv="base", prefix=""):
    """
    List the empty dirs on the master
    """
    load = {"saltenv": saltenv, "prefix": prefix, "cmd": "_file_list_emptydirs"}
    return (
        salt.utils.data.decode(self.channel.send(load))
        if six.PY2
        else self.channel.send(load)
    )
# Buggy code
def dir_list(self, saltenv="base", prefix=""):
    """
    List the dirs on the master
    """
    load = {"saltenv": saltenv, "prefix": prefix, "cmd": "_dir_list"}
    return self.channel.send(load)


# Traceback (UnicodeEncodeError)
ID: test1
Function: file.recurse
Name: /root/group2test
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1703, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2807, in recurse
manage_file(dest, src)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2685, in manage_file
**pass_kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1814, in managed
__env__
File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 3490, in source_list
contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-34: ordinal not in range(128)
Started: 20:08:21.608398
Duration: 1467.811 ms
Changes:

# Fixed code
def dir_list(self, saltenv="base", prefix=""):
    """
    List the dirs on the master
    """
    load = {"saltenv": saltenv, "prefix": prefix, "cmd": "_dir_list"}
    return (
        salt.utils.data.decode(self.channel.send(load))
        if six.PY2
        else self.channel.send(load)
    )
# Buggy code
def symlink_list(self, saltenv="base", prefix=""):
    """
    List symlinked files and dirs on the master
    """
    load = {"saltenv": saltenv, "prefix": prefix, "cmd": "_symlink_list"}
    return self.channel.send(load)


# Traceback (UnicodeEncodeError)
ID: test1
Function: file.recurse
Name: /root/group2test
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1703, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2807, in recurse
manage_file(dest, src)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2685, in manage_file
**pass_kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1814, in managed
__env__
File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 3490, in source_list
contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-34: ordinal not in range(128)
Started: 20:08:21.608398
Duration: 1467.811 ms
Changes:

# Fixed code
def symlink_list(self, saltenv="base", prefix=""):
    """
    List symlinked files and dirs on the master
    """
    load = {"saltenv": saltenv, "prefix": prefix, "cmd": "_symlink_list"}
    return (
        salt.utils.data.decode(self.channel.send(load))
        if six.PY2
        else self.channel.send(load)
    )
# Buggy code
def list_env(self, saltenv="base"):
    """
    Return a list of the files in the file server's specified environment
    """
    load = {"saltenv": saltenv, "cmd": "_file_list"}
    return self.channel.send(load)


# Traceback (UnicodeEncodeError)
ID: test1
Function: file.recurse
Name: /root/group2test
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1703, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2807, in recurse
manage_file(dest, src)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2685, in manage_file
**pass_kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1814, in managed
__env__
File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 3490, in source_list
contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-34: ordinal not in range(128)
Started: 20:08:21.608398
Duration: 1467.811 ms
Changes:

# Fixed code
def list_env(self, saltenv="base"):
    """
    Return a list of the files in the file server's specified environment
    """
    load = {"saltenv": saltenv, "cmd": "_file_list"}
    return (
        salt.utils.data.decode(self.channel.send(load))
        if six.PY2
        else self.channel.send(load)
    )
# Buggy code
def envs(self):
    """
    Return a list of available environments
    """
    load = {"cmd": "_file_envs"}
    return self.channel.send(load)


# Traceback (UnicodeEncodeError)
ID: test1
Function: file.recurse
Name: /root/group2test
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1703, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2807, in recurse
manage_file(dest, src)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2685, in manage_file
**pass_kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1814, in managed
__env__
File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 3490, in source_list
contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-34: ordinal not in range(128)
Started: 20:08:21.608398
Duration: 1467.811 ms
Changes:

# Fixed code
def envs(self):
    """
    Return a list of available environments
    """
    load = {"cmd": "_file_envs"}
    return (
        salt.utils.data.decode(self.channel.send(load))
        if six.PY2
        else self.channel.send(load)
    )
# Buggy code
def master_opts(self):
    """
    Return the master opts data
    """
    load = {"cmd": "_master_opts"}
    return self.channel.send(load)


# Traceback (UnicodeEncodeError)
ID: test1
Function: file.recurse
Name: /root/group2test
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1703, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2807, in recurse
manage_file(dest, src)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2685, in manage_file
**pass_kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1814, in managed
__env__
File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 3490, in source_list
contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-34: ordinal not in range(128)
Started: 20:08:21.608398
Duration: 1467.811 ms
Changes:

# Fixed code
def master_opts(self):
    """
    Return the master opts data
    """
    load = {"cmd": "_master_opts"}
    return (
        salt.utils.data.decode(self.channel.send(load))
        if six.PY2
        else self.channel.send(load)
    )
# Buggy code
def master_tops(self):
    """
    Return the metadata derived from the master_tops system
    """
    load = {"cmd": "_master_tops", "id": self.opts["id"], "opts": self.opts}
    if self.auth:
        load["tok"] = self.auth.gen_token(b"salt")
    return self.channel.send(load)


# Traceback (UnicodeEncodeError)
ID: test1
Function: file.recurse
Name: /root/group2test
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1703, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2807, in recurse
manage_file(dest, src)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2685, in manage_file
**pass_kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1814, in managed
__env__
File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 3490, in source_list
contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-34: ordinal not in range(128)
Started: 20:08:21.608398
Duration: 1467.811 ms
Changes:

# Fixed code
def master_tops(self):
    """
    Return the metadata derived from the master_tops system
    """
    load = {"cmd": "_master_tops", "id": self.opts["id"], "opts": self.opts}
    if self.auth:
        load["tok"] = self.auth.gen_token(b"salt")
    return (
        salt.utils.data.decode(self.channel.send(load))
        if six.PY2
        else self.channel.send(load)
    )
# Buggy code
def __file_hash_and_stat(self, load):
    """
    Common code for hashing and stating files
    """
    if "env" in load:
        # "env" is not supported; Use "saltenv".
        load.pop("env")

    if "path" not in load or "saltenv" not in load:
        return "", None
    if not isinstance(load["saltenv"], six.string_types):
        load["saltenv"] = six.text_type(load["saltenv"])

    fnd = self.find_file(salt.utils.locales.sdecode(load["path"]), load["saltenv"])
    if not fnd.get("back"):
        return "", None
    stat_result = fnd.get("stat", None)
    fstr = "{0}.file_hash".format(fnd["back"])
    if fstr in self.servers:
        return self.servers[fstr](load, fnd), stat_result
    return "", None


# Traceback (UnicodeEncodeError)
ID: test1
Function: file.recurse
Name: /root/group2test
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1746, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/loader.py", line 1703, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2807, in recurse
manage_file(dest, src)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 2685, in manage_file
**pass_kwargs)
File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1814, in managed
__env__
File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 3490, in source_list
contextkey = '{0}_|-{1}_|-{2}'.format(source, source_hash, saltenv)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-34: ordinal not in range(128)
Started: 20:08:21.608398
Duration: 1467.811 ms
Changes:

# Fixed code
def __file_hash_and_stat(self, load):
    """
    Common code for hashing and stating files
    """
    if "env" in load:
        # "env" is not supported; Use "saltenv".
        load.pop("env")

    if "path" not in load or "saltenv" not in load:
        return "", None
    if not isinstance(load["saltenv"], six.string_types):
        load["saltenv"] = six.text_type(load["saltenv"])

    fnd = self.find_file(
        salt.utils.stringutils.to_unicode(load["path"]), load["saltenv"]
    )
    if not fnd.get("back"):
        return "", None
    stat_result = fnd.get("stat", None)
    fstr = "{0}.file_hash".format(fnd["back"])
    if fstr in self.servers:
        return self.servers[fstr](load, fnd), stat_result
    return "", None