# Buggy code
def find_file(self, path, saltenv, back=None):
    """
    Find the path and return the fnd structure, this structure is passed
    to other backend interfaces.
    """
    path = salt.utils.locales.sdecode(path)
    saltenv = salt.utils.locales.sdecode(saltenv)
    back = self.backends(back)
    kwargs = {}
    fnd = {"path": "", "rel": ""}
    if os.path.isabs(path):
        return fnd
    if "../" in path:
        return fnd
    if salt.utils.url.is_escaped(path):
        # don't attempt to find URL query arguements in the path
        path = salt.utils.url.unescape(path)
    else:
        if "?" in path:
            hcomps = path.split("?")
            path = hcomps[0]
            comps = hcomps[1].split("&")
            for comp in comps:
                if "=" not in comp:
                    # Invalid option, skip it
                    continue
                args = comp.split("=", 1)
                kwargs[args[0]] = args[1]

    if "env" in kwargs:
        # "env" is not supported; Use "saltenv".
        kwargs.pop("env")
    if "saltenv" in kwargs:
        saltenv = kwargs.pop("saltenv")

    if not isinstance(saltenv, six.string_types):
        saltenv = six.text_type(saltenv)

    for fsb in back:
        fstr = "{0}.find_file".format(fsb)
        if fstr in self.servers:
            fnd = self.servers[fstr](path, saltenv, **kwargs)
            if fnd.get("path"):
                fnd["back"] = fsb
                return fnd
    return fnd


# 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 find_file(self, path, saltenv, back=None):
    """
    Find the path and return the fnd structure, this structure is passed
    to other backend interfaces.
    """
    path = salt.utils.stringutils.to_unicode(path)
    saltenv = salt.utils.stringutils.to_unicode(saltenv)
    back = self.backends(back)
    kwargs = {}
    fnd = {"path": "", "rel": ""}
    if os.path.isabs(path):
        return fnd
    if "../" in path:
        return fnd
    if salt.utils.url.is_escaped(path):
        # don't attempt to find URL query arguements in the path
        path = salt.utils.url.unescape(path)
    else:
        if "?" in path:
            hcomps = path.split("?")
            path = hcomps[0]
            comps = hcomps[1].split("&")
            for comp in comps:
                if "=" not in comp:
                    # Invalid option, skip it
                    continue
                args = comp.split("=", 1)
                kwargs[args[0]] = args[1]

    if "env" in kwargs:
        # "env" is not supported; Use "saltenv".
        kwargs.pop("env")
    if "saltenv" in kwargs:
        saltenv = kwargs.pop("saltenv")

    if not isinstance(saltenv, six.string_types):
        saltenv = six.text_type(saltenv)

    for fsb in back:
        fstr = "{0}.find_file".format(fsb)
        if fstr in self.servers:
            fnd = self.servers[fstr](path, saltenv, **kwargs)
            if fnd.get("path"):
                fnd["back"] = fsb
                return fnd
    return fnd