# Buggy code
def check_requisite(self, low, running, chunks, pre=False):
    """
    Look into the running data to check the status of all requisite
    states
    """
    present = False
    # If mod_watch is not available make it a require
    if "watch" in low:
        if "{0}.mod_watch".format(low["state"]) not in self.states:
            if "require" in low:
                low["require"].extend(low.pop("watch"))
            else:
                low["require"] = low.pop("watch")
        else:
            present = True
    if "require" in low:
        present = True
    if "prerequired" in low:
        present = True
    if "prereq" in low:
        present = True
    if not present:
        return "met"
    reqs = {"require": [], "watch": [], "prereq": []}
    if pre:
        reqs["prerequired"] = []
    for r_state in reqs:
        if r_state in low:
            for req in low[r_state]:
                req = trim_req(req)
                found = False
                for chunk in chunks:
                    req_key = next(iter(req))
                    req_val = req[req_key]
                    if req_val is None:
                        continue
                    if fnmatch.fnmatch(chunk["name"], req_val) or fnmatch.fnmatch(
                        chunk["__id__"], req_val
                    ):
                        if chunk["state"] == req_key:
                            found = True
                            reqs[r_state].append(chunk)
                    elif req_key == "sls":
                        # Allow requisite tracking of entire sls files
                        if fnmatch.fnmatch(chunk["__sls__"], req_val):
                            found = True
                            reqs[r_state].append(chunk)
                if not found:
                    return "unmet"
    fun_stats = set()
    for r_state, chunks in reqs.items():
        if r_state == "prereq":
            run_dict = self.pre
        else:
            run_dict = running
        for chunk in chunks:
            tag = _gen_tag(chunk)
            if tag not in run_dict:
                fun_stats.add("unmet")
                continue
            if run_dict[tag]["result"] is False:
                fun_stats.add("fail")
                continue
            if r_state == "watch" and run_dict[tag]["changes"]:
                fun_stats.add("change")
                continue
            if r_state == "prereq" and run_dict[tag]["result"] is None:
                fun_stats.add("premet")
            if r_state == "prereq" and not run_dict[tag]["result"] is None:
                fun_stats.add("pre")
            else:
                fun_stats.add("met")

    if "unmet" in fun_stats:
        return "unmet"
    elif "fail" in fun_stats:
        return "fail"
    elif "pre" in fun_stats:
        if "premet" in fun_stats:
            return "met"
        return "pre"
    elif "change" in fun_stats:
        return "change"
    return "met"


# Traceback (TypeError)
[DEBUG   ] "Missing args" caused by exc: 'NoneType' object is not iterable
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/salt/minion.py", line 443, in _thread_return
ret['return'] = func(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/salt/modules/state.py", line 201, in highstate
cache_name=kwargs.get('cache_name', 'highstate')
File "/usr/lib/pymodules/python2.7/salt/state.py", line 2087, in call_highstate
return self.state.call_high(high)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1415, in call_high
ret = self.call_chunks(chunks)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1233, in call_chunks
running = self.call_chunk(low, running, chunks)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1316, in call_chunk
status = self.check_requisite(low, running, chunks)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1270, in check_requisite
for req in low[r_state]:
TypeError: 'NoneType' object is not iterable

# Fixed code
def check_requisite(self, low, running, chunks, pre=False):
    """
    Look into the running data to check the status of all requisite
    states
    """
    present = False
    # If mod_watch is not available make it a require
    if "watch" in low:
        if "{0}.mod_watch".format(low["state"]) not in self.states:
            if "require" in low:
                low["require"].extend(low.pop("watch"))
            else:
                low["require"] = low.pop("watch")
        else:
            present = True
    if "require" in low:
        present = True
    if "prerequired" in low:
        present = True
    if "prereq" in low:
        present = True
    if not present:
        return "met"
    reqs = {"require": [], "watch": [], "prereq": []}
    if pre:
        reqs["prerequired"] = []
    for r_state in reqs:
        if r_state in low and low[r_state] is not None:
            for req in low[r_state]:
                req = trim_req(req)
                found = False
                for chunk in chunks:
                    req_key = next(iter(req))
                    req_val = req[req_key]
                    if req_val is None:
                        continue
                    if fnmatch.fnmatch(chunk["name"], req_val) or fnmatch.fnmatch(
                        chunk["__id__"], req_val
                    ):
                        if chunk["state"] == req_key:
                            found = True
                            reqs[r_state].append(chunk)
                    elif req_key == "sls":
                        # Allow requisite tracking of entire sls files
                        if fnmatch.fnmatch(chunk["__sls__"], req_val):
                            found = True
                            reqs[r_state].append(chunk)
                if not found:
                    return "unmet"
    fun_stats = set()
    for r_state, chunks in reqs.items():
        if r_state == "prereq":
            run_dict = self.pre
        else:
            run_dict = running
        for chunk in chunks:
            tag = _gen_tag(chunk)
            if tag not in run_dict:
                fun_stats.add("unmet")
                continue
            if run_dict[tag]["result"] is False:
                fun_stats.add("fail")
                continue
            if r_state == "watch" and run_dict[tag]["changes"]:
                fun_stats.add("change")
                continue
            if r_state == "prereq" and run_dict[tag]["result"] is None:
                fun_stats.add("premet")
            if r_state == "prereq" and not run_dict[tag]["result"] is None:
                fun_stats.add("pre")
            else:
                fun_stats.add("met")

    if "unmet" in fun_stats:
        return "unmet"
    elif "fail" in fun_stats:
        return "fail"
    elif "pre" in fun_stats:
        if "premet" in fun_stats:
            return "met"
        return "pre"
    elif "change" in fun_stats:
        return "change"
    return "met"