# Buggy code
def info(name):
    """
    Return information for the specified user

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.info someuser
    """
    try:
        data = pwd.getpwnam(name)
        ret = {"name": data.pw_name, "passwd": data.pw_passwd}
    except KeyError:
        return {"name": "", "passwd": ""}

    if not isinstance(name, six.string_types):
        name = six.text_type(name)
    if ":" in name:
        raise SaltInvocationError("Invalid username '{0}'".format(name))

    if __salt__["cmd.has_exec"]("pw"):
        change, expire = __salt__["cmd.run_stdout"](
            ["pw", "user", "show", name], python_shell=False
        ).split(":")[5:7]
    elif __grains__["kernel"] in ("NetBSD", "OpenBSD"):
        try:
            with salt.utils.files.fopen("/etc/master.passwd", "r") as fp_:
                for line in fp_:
                    line = salt.utils.stringutils.to_unicode(line)
                    if line.startswith("{0}:".format(name)):
                        key = line.split(":")
                        change, expire = key[5:7]
                        ret["passwd"] = six.text_type(key[1])
                        break
        except IOError:
            change = expire = None
    else:
        change = expire = None

    try:
        ret["change"] = int(change)
    except ValueError:
        pass

    try:
        ret["expire"] = int(expire)
    except ValueError:
        pass

    return ret


# Traceback (ValueError)
ID: user12345
Function: user.present
Name: 12345
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/salt/state.py", line 1913, in call
**cdata['kwargs'])
File "/usr/local/lib/python3.6/site-packages/salt/loader.py", line 1898, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/salt/states/user.py", line 563, in present
allow_gid_change)
File "/usr/local/lib/python3.6/site-packages/salt/states/user.py", line 97, in _changes
lshad = __salt__['shadow.info'](name)
File "/usr/local/lib/python3.6/site-packages/salt/modules/bsd_shadow.py", line 77, in info
python_shell=False).split(':')[5:7]
ValueError: not enough values to unpack (expected 2, got 0)
Started: 12:03:39.145637
Duration: 33.27 ms
Changes:

# Fixed code
def info(name):
    """
    Return information for the specified user

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.info someuser
    """
    try:
        data = pwd.getpwnam(name)
        ret = {"name": data.pw_name, "passwd": data.pw_passwd}
    except KeyError:
        return {"name": "", "passwd": ""}

    if not isinstance(name, six.string_types):
        name = six.text_type(name)
    if ":" in name:
        raise SaltInvocationError("Invalid username '{0}'".format(name))

    if __salt__["cmd.has_exec"]("pw"):
        change, expire = __salt__["cmd.run_stdout"](
            ["pw", "usershow", "-n", name], python_shell=False
        ).split(":")[5:7]
    elif __grains__["kernel"] in ("NetBSD", "OpenBSD"):
        try:
            with salt.utils.files.fopen("/etc/master.passwd", "r") as fp_:
                for line in fp_:
                    line = salt.utils.stringutils.to_unicode(line)
                    if line.startswith("{0}:".format(name)):
                        key = line.split(":")
                        change, expire = key[5:7]
                        ret["passwd"] = six.text_type(key[1])
                        break
        except IOError:
            change = expire = None
    else:
        change = expire = None

    try:
        ret["change"] = int(change)
    except ValueError:
        pass

    try:
        ret["expire"] = int(expire)
    except ValueError:
        pass

    return ret