# Buggy code
def cmd_subset(
    self,
    tgt,
    fun,
    arg=(),
    tgt_type="glob",
    ret="",
    kwarg=None,
    sub=3,
    cli=False,
    progress=False,
    **kwargs,
):
    """
    Execute a command on a random subset of the targeted systems

    The function signature is the same as :py:meth:`cmd` with the
    following exceptions.

    :param sub: The number of systems to execute on

    .. code-block:: python

        >>> SLC.cmd_subset('*', 'test.ping', sub=1)
        {'jerry': True}
    """
    if "expr_form" in kwargs:
        salt.utils.warn_until(
            "Fluorine",
            "The target type should be passed using the 'tgt_type' "
            "argument instead of 'expr_form'. Support for using "
            "'expr_form' will be removed in Salt Fluorine.",
        )
        tgt_type = kwargs.pop("expr_form")

    minion_ret = self.cmd(tgt, "sys.list_functions", tgt_type=tgt_type, **kwargs)
    minions = list(minion_ret)
    random.shuffle(minions)
    f_tgt = []
    for minion in minions:
        if fun in minion_ret[minion]:
            f_tgt.append(minion)
        if len(f_tgt) >= sub:
            break
    func = self.cmd
    if cli:
        func = self.cmd_cli
    return func(
        f_tgt,
        fun,
        arg,
        tgt_type="list",
        ret=ret,
        kwarg=kwarg,
        progress=progress,
        **kwargs,
    )


# Traceback (ValueError)
$ sudo salt-run state.orch my-orch

[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/state.py", line 1851, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1795, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/states/saltmod.py", line 272, in state
cmd_ret = __salt__['saltutil.cmd'](tgt, fun, **cmd_kw)
File "/usr/lib/python2.7/site-packages/salt/modules/saltutil.py", line 1322, in cmd
client, tgt, fun, arg, timeout, tgt_type, ret, kwarg, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/modules/saltutil.py", line 1287, in _exec
fcn_ret.update(ret_comp)
ValueError: dictionary update sequence element #0 has length 1; 2 is required

my-vm.example.com_master:
----------
ID: problem
Function: salt.state
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/state.py", line 1851, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1795, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/states/saltmod.py", line 272, in state
cmd_ret = __salt__['saltutil.cmd'](tgt, fun, **cmd_kw)
File "/usr/lib/python2.7/site-packages/salt/modules/saltutil.py", line 1322, in cmd
client, tgt, fun, arg, timeout, tgt_type, ret, kwarg, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/modules/saltutil.py", line 1287, in _exec
fcn_ret.update(ret_comp)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
Started: 03:38:45.070976
Duration: 2349.035 ms
Changes:

Summary for my-vm.example.com_master
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   2.349 s

# Fixed code
def cmd_subset(
    self,
    tgt,
    fun,
    arg=(),
    tgt_type="glob",
    ret="",
    kwarg=None,
    sub=3,
    cli=False,
    progress=False,
    **kwargs,
):
    """
    Execute a command on a random subset of the targeted systems

    The function signature is the same as :py:meth:`cmd` with the
    following exceptions.

    :param sub: The number of systems to execute on
    :param cli: When this is set to True, a generator is returned,
                otherwise a dictionary of the minion returns is returned

    .. code-block:: python

        >>> SLC.cmd_subset('*', 'test.ping', sub=1)
        {'jerry': True}
    """
    if "expr_form" in kwargs:
        salt.utils.warn_until(
            "Fluorine",
            "The target type should be passed using the 'tgt_type' "
            "argument instead of 'expr_form'. Support for using "
            "'expr_form' will be removed in Salt Fluorine.",
        )
        tgt_type = kwargs.pop("expr_form")

    minion_ret = self.cmd(tgt, "sys.list_functions", tgt_type=tgt_type, **kwargs)
    minions = list(minion_ret)
    random.shuffle(minions)
    f_tgt = []
    for minion in minions:
        if fun in minion_ret[minion]:
            f_tgt.append(minion)
        if len(f_tgt) >= sub:
            break
    func = self.cmd
    if cli:
        func = self.cmd_cli
    return func(
        f_tgt,
        fun,
        arg,
        tgt_type="list",
        ret=ret,
        kwarg=kwarg,
        progress=progress,
        **kwargs,
    )