# Buggy code
def touch(name, atime=None, mtime=None, makedirs=False):
    """
    Replicate the 'nix "touch" command to create a new empty
    file or update the atime and mtime of an existing file.

    Note that if you just want to create a file and don't care about atime or
    mtime, you should use ``file.managed`` instead, as it is more
    feature-complete.  (Just leave out the ``source``/``template``/``contents``
    arguments, and it will just create the file and/or check its permissions,
    without messing with contents)

    name
        name of the file

    atime
        atime of the file

    mtime
        mtime of the file

    makedirs
        whether we should create the parent directory/directories in order to
        touch the file

    Usage:

    .. code-block:: yaml

        /var/log/httpd/logrotate.empty:
          file.touch

    .. versionadded:: 0.9.5
    """
    ret = {
        "name": name,
        "changes": {},
    }
    if not os.path.isabs(name):
        return _error(ret, "Specified file {0} is not an absolute path".format(name))

    if __opts__["test"]:
        ret["result"], ret["comment"] = _check_touch(name, atime, mtime)
        return ret

    if makedirs:
        __salt__["file.makedirs"](name)
    if not os.path.isdir(os.path.dirname(name)):
        return _error(ret, "Directory not present to touch file {0}".format(name))

    extant = os.path.exists(name)

    ret["result"] = __salt__["file.touch"](name, atime, mtime)
    if not extant and ret["result"]:
        ret["comment"] = "Created empty file {0}".format(name)
        ret["changes"]["new"] = name
    elif extant and ret["result"]:
        ret["comment"] = "Updated times on {0} {1}".format(
            "directory" if os.path.isdir(name) else "file", name
        )
        ret["changes"]["touched"] = name

    return ret


# Traceback (TypeError)
2014-11-24 16:03:42,245 [salt.minion      ][WARNING ] TypeError encountered executing state.highstate: expected string or buffer. See debug log for more info.  Possibly a missing arguments issue:  ArgSpec(args=['test', 'queue'], varargs=None, keywords='kwargs', defaults=(None, False))
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/salt/minion.py", line 809, in _thread_return
return_data = func(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/salt/modules/state.py", line 275, in highstate
force=kwargs.get('force', False)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 2546, in call_highstate
return self.state.call_high(high)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1715, in call_high
ret = self.call_chunks(chunks)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1437, in call_chunks
running = self.call_chunk(low, running, chunks)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1562, in call_chunk
status = self.check_requisite(low, running, chunks, True)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1489, in check_requisite
if (fnmatch.fnmatch(chunk['name'], req_val) or
File "/usr/lib/python2.7/fnmatch.py", line 43, in fnmatch
return fnmatchcase(name, pat)
File "/usr/lib/python2.7/fnmatch.py", line 79, in fnmatchcase
return _cache[pat].match(name) is not None
TypeError: expected string or buffer

# Fixed code
def touch(name, atime=None, mtime=None, makedirs=False):
    """
    Replicate the 'nix "touch" command to create a new empty
    file or update the atime and mtime of an existing file.

    Note that if you just want to create a file and don't care about atime or
    mtime, you should use ``file.managed`` instead, as it is more
    feature-complete.  (Just leave out the ``source``/``template``/``contents``
    arguments, and it will just create the file and/or check its permissions,
    without messing with contents)

    name
        name of the file

    atime
        atime of the file

    mtime
        mtime of the file

    makedirs
        whether we should create the parent directory/directories in order to
        touch the file

    Usage:

    .. code-block:: yaml

        /var/log/httpd/logrotate.empty:
          file.touch

    .. versionadded:: 0.9.5
    """
    ret = {
        "name": name,
        "changes": {},
    }
    if not name:
        return _error(ret, "Must provide name to file.touch")
    if not os.path.isabs(name):
        return _error(ret, "Specified file {0} is not an absolute path".format(name))

    if __opts__["test"]:
        ret["result"], ret["comment"] = _check_touch(name, atime, mtime)
        return ret

    if makedirs:
        __salt__["file.makedirs"](name)
    if not os.path.isdir(os.path.dirname(name)):
        return _error(ret, "Directory not present to touch file {0}".format(name))

    extant = os.path.exists(name)

    ret["result"] = __salt__["file.touch"](name, atime, mtime)
    if not extant and ret["result"]:
        ret["comment"] = "Created empty file {0}".format(name)
        ret["changes"]["new"] = name
    elif extant and ret["result"]:
        ret["comment"] = "Updated times on {0} {1}".format(
            "directory" if os.path.isdir(name) else "file", name
        )
        ret["changes"]["touched"] = name

    return ret