# Buggy code
def _get_policy_object(
    platform,
    filters=None,
    pillar_key="acl",
    pillarenv=None,
    saltenv=None,
    merge_pillar=True,
):
    """
    Return an instance of the ``_Policy`` class given the filters config.
    """
    policy = _Policy()
    policy_filters = []
    if not filters:
        filters = {}
    for filter_name, filter_config in six.iteritems(filters):
        header = aclgen.policy.Header()  # same header everywhere
        target_opts = [platform, filter_name]
        filter_options = filter_config.pop("options", None)
        if filter_options:
            filter_options = _make_it_list(filter_options, filter_name, filter_options)
            # make sure the filter options are sent as list
            target_opts.extend(filter_options)
        target = aclgen.policy.Target(target_opts)
        header.AddObject(target)
        filter_terms = []
        for term_name, term_fields in six.iteritems(filter_config):
            term = _get_term_object(
                filter_name,
                term_name,
                pillar_key=pillar_key,
                pillarenv=pillarenv,
                saltenv=saltenv,
                merge_pillar=merge_pillar,
                **term_fields,
            )
            filter_terms.append(term)
        policy_filters.append((header, filter_terms))
    policy.filters = policy_filters
    log.debug("Policy config:")
    log.debug(str(policy))
    platform_generator = _import_platform_generator(platform)
    policy_config = platform_generator(policy, 2)
    log.debug("Generating policy config for {platform}:".format(platform=platform))
    log.debug(str(policy_config))
    return policy_config


# Traceback (TypeError)
2017-03-18 13:52:24,471 [salt.minion                                                    ][INFO    ][21597] User root Executing command netacl.load_filter_config with jid 20170318135224468263
2017-03-18 13:52:24,471 [salt.minion                                                    ][DEBUG   ][21597] Command details {'tgt_type': 'glob', 'jid': '20170318135224468263', 'tgt': 'veos1', 'ret': '', 'user': 'root', 'arg': ['filter-name', {'test': True, 'debug': True, 'terms': '{"term1": {"source_address": "4.3.2.1", "destination_address": "1.2.3.4", "action"="accept"}}', '__kwarg_
_': True}], 'fun': 'netacl.load_filter_config'}
2017-03-18 13:52:24,472 [salt.minion                                                    ][INFO    ][21597] Starting a new job with PID 21597
2017-03-18 13:52:24,472 [salt.minion                                                    ][WARNING ][21597] Passed invalid arguments to netacl.load_filter_config: load_filter_config() got an unexpected k
eyword argument '__pub_user'
<snip docstring>
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1445, in _thread_return
return_data = executor.execute()
File "/usr/lib/python2.7/dist-packages/salt/executors/direct_call.py", line 28, in execute
return self.func(*self.args, **self.kwargs)
File "/usr/lib/python2.7/dist-packages/salt/utils/napalm.py", line 333, in func_wrapper
return func(*args, **kwargs)
TypeError: load_filter_config() got an unexpected keyword argument '__pub_user'
2017-03-18 13:52:24,472 [salt.minion                                                    ][DEBUG   ][21597] Minion return retry timer set to 8 seconds (randomized)
2017-03-18 13:52:24,472 [salt.minion                                                    ][INFO    ][21597] Returning information for job: 20170318135224468263

# Fixed code
def _get_policy_object(
    platform,
    filters=None,
    pillar_key="acl",
    pillarenv=None,
    saltenv=None,
    merge_pillar=True,
):
    """
    Return an instance of the ``_Policy`` class given the filters config.
    """
    policy = _Policy()
    policy_filters = []
    if not filters:
        filters = {}
    for filter_name, filter_config in six.iteritems(filters):
        header = aclgen.policy.Header()  # same header everywhere
        target_opts = [platform, filter_name]
        filter_options = filter_config.pop("options", None)
        if filter_options:
            filter_options = _make_it_list({}, filter_name, filter_options)
            # make sure the filter options are sent as list
            target_opts.extend(filter_options)
        target = aclgen.policy.Target(target_opts)
        header.AddObject(target)
        filter_terms = []
        for term_name, term_fields in six.iteritems(filter_config):
            term = _get_term_object(
                filter_name,
                term_name,
                pillar_key=pillar_key,
                pillarenv=pillarenv,
                saltenv=saltenv,
                merge_pillar=merge_pillar,
                **term_fields,
            )
            filter_terms.append(term)
        policy_filters.append((header, filter_terms))
    policy.filters = policy_filters
    log.debug("Policy config:")
    log.debug(str(policy))
    platform_generator = _import_platform_generator(platform)
    policy_config = platform_generator(policy, 2)
    log.debug("Generating policy config for {platform}:".format(platform=platform))
    log.debug(str(policy_config))
    return policy_config