# Buggy code
def _compute_diff(configured, expected):
    """Computes the differences between the actual config and the expected config"""

    diff = {"add": {}, "update": {}, "remove": {}}

    configured_users = set(configured.keys())
    expected_users = set(expected.keys())

    add_usernames = expected_users - configured_users
    remove_usernames = configured_users - expected_users
    common_usernames = expected_users & configured_users

    add = dict((username, expected.get(username)) for (username, _) in add_usernames)
    remove = dict(
        (username, configured.get(username)) for (username, _) in remove_usernames
    )
    update = {}

    for username in common_usernames:
        user_configuration = configured.get(username)
        user_expected = expected.get(username)
        if user_configuration == user_expected:
            continue
        update[username] = {}
        for field, field_value in six.iteritems(user_expected):
            if user_configuration.get(field) != field_value:
                update[username][field] = field_value

    diff.update({"add": add, "update": update, "remove": remove})

    return diff


# Traceback (ValueError)
ID: cf_users
Function: netusers.managed
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1744, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1702, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/states/netusers.py", line 357, in managed
diff = _compute_diff(configured_users, expected_users)
File "/usr/lib/python2.7/dist-packages/salt/states/netusers.py", line 114, in _compute_diff
add = dict((username, expected.get(username)) for (username, _) in add_usernames)
File "/usr/lib/python2.7/dist-packages/salt/states/netusers.py", line 114, in <genexpr>
add = dict((username, expected.get(username)) for (username, _) in add_usernames)
ValueError: too many values to unpack
Started: 19:52:51.938999
Duration: 193.051 ms
Changes:

# Fixed code
def _compute_diff(configured, expected):
    """Computes the differences between the actual config and the expected config"""

    diff = {"add": {}, "update": {}, "remove": {}}

    configured_users = set(configured.keys())
    expected_users = set(expected.keys())

    add_usernames = expected_users - configured_users
    remove_usernames = configured_users - expected_users
    common_usernames = expected_users & configured_users

    add = dict((username, expected.get(username)) for username in add_usernames)
    remove = dict((username, configured.get(username)) for username in remove_usernames)
    update = {}

    for username in common_usernames:
        user_configuration = configured.get(username)
        user_expected = expected.get(username)
        if user_configuration == user_expected:
            continue
        update[username] = {}
        for field, field_value in six.iteritems(user_expected):
            if user_configuration.get(field) != field_value:
                update[username][field] = field_value

    diff.update({"add": add, "update": update, "remove": remove})

    return diff