# Buggy code
def run_job(self, name):
    """
    Run a schedule job now
    """
    data = self._get_schedule().get(name, {})

    if "function" in data:
        func = data["function"]
    elif "func" in data:
        func = data["func"]
    elif "fun" in data:
        func = data["fun"]
    else:
        func = None
    if func not in self.functions:
        log.info("Invalid function: %s in scheduled job %s.", func, name)

    if "name" not in data:
        data["name"] = name
    log.info("Running Job: %s", name)

    if not self.standalone:
        data = self._check_max_running(func, data, self.opts, datetime.datetime.now())

    # Grab run, assume True
    run = data.get("run", True)
    if run:
        self._run_job(func, data)


# Traceback (KeyError)
2019-09-25 14:06:41,391 [salt.utils.schedule:461 ][INFO    ][6910] Running Job: test-scheduler-present
2019-09-25 14:06:41,391 [tornado.application:611 ][ERROR   ][6910] Exception in callback <functools.partial object at 0x7f5bcc528520>
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/tornado/ioloop.py", line 591, in _run_callback
ret = callback()
File "/usr/lib64/python2.7/site-packages/tornado/stack_context.py", line 274, in null_wrapper
return fn(*args, **kwargs)
File "/usr/lib64/python2.7/site-packages/tornado/ioloop.py", line 597, in <lambda>
self.add_future(ret, lambda f: f.result())
File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 214, in result
raise_exc_info(self._exc_info)
File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 888, in run
yielded = self.gen.throw(*exc_info)
File "/usr/lib/python2.7/site-packages/salt/minion.py", line 959, in handle_event
yield [minion.handle_event(package) for minion in self.minions]
File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 882, in run
value = future.result()
File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 214, in result
raise_exc_info(self._exc_info)
File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 668, in callback
result_list.append(f.result())
File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 214, in result
raise_exc_info(self._exc_info)
File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 232, in wrapper
yielded = next(result)
File "/usr/lib/python2.7/site-packages/salt/minion.py", line 2371, in handle_event
self.manage_schedule(tag, data)
File "/usr/lib/python2.7/site-packages/salt/minion.py", line 2233, in manage_schedule
self.schedule.run_job(name)
File "/usr/lib/python2.7/site-packages/salt/utils/schedule.py", line 467, in run_job
datetime.datetime.now())
File "/usr/lib/python2.7/site-packages/salt/utils/schedule.py", line 212, in _check_max_running
if not data['run']:
KeyError: u'run'

# Fixed code
def run_job(self, name):
    """
    Run a schedule job now
    """
    data = self._get_schedule().get(name, {})

    if "function" in data:
        func = data["function"]
    elif "func" in data:
        func = data["func"]
    elif "fun" in data:
        func = data["fun"]
    else:
        func = None
    if func not in self.functions:
        log.info("Invalid function: %s in scheduled job %s.", func, name)

    if "name" not in data:
        data["name"] = name

    # Assume run should be True until we check max_running
    if "run" not in data:
        data["run"] = True

    if not self.standalone:
        data = self._check_max_running(func, data, self.opts, datetime.datetime.now())

    # Grab run, assume True
    if data.get("run"):
        log.info("Running Job: %s", name)
        self._run_job(func, data)