# Buggy code
def create_from_data(cls, **kwargs):
    # Convert the datetime for the event's creation
    # appropriately, and include a time zone for it.
    #
    # In the event of any issue, throw it out, and Django will just save
    # the current time.
    try:
        if not isinstance(kwargs["created"], datetime.datetime):
            kwargs["created"] = parse_datetime(kwargs["created"])
        if not kwargs["created"].tzinfo:
            kwargs["created"] = kwargs["created"].replace(tzinfo=utc)
    except (KeyError, ValueError):
        kwargs.pop("created", None)

    sanitize_event_keys(kwargs, cls.VALID_KEYS)
    event = cls.objects.create(**kwargs)
    if isinstance(event, AdHocCommandEvent):
        analytics_logger.info(
            "Event data saved.", extra=dict(python_objects=dict(job_event=event))
        )
    return event


# Traceback (TypeError)
awx_1        | 2019-10-04 16:26:53,567 ERROR    awx.main.commands.run_callback_receiver Callback Task Processor Raised Exception: TypeError("InventoryUpdateEvent() got an unexpected keyword argument 'workflow_job_id'",)
awx_1        | 2019-10-04 16:26:53,568 ERROR    awx.main.commands.run_callback_receiver Detail: Traceback (most recent call last):
awx_1        |   File "/awx_devel/awx/main/dispatch/worker/callback.py", line 107, in perform_work
awx_1        |     _save_event_data()
awx_1        |   File "/awx_devel/awx/main/dispatch/worker/callback.py", line 45, in _save_event_data
awx_1        |     cls.create_from_data(**body)
awx_1        |   File "/awx_devel/awx/main/models/events.py", line 622, in create_from_data
awx_1        |     event = cls.objects.create(**kwargs)
awx_1        |   File "/venv/awx/lib64/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
awx_1        |     return getattr(self.get_queryset(), name)(*args, **kwargs)
awx_1        |   File "/venv/awx/lib64/python3.6/site-packages/django/db/models/query.py", line 420, in create
awx_1        |     obj = self.model(**kwargs)
awx_1        |   File "/venv/awx/lib64/python3.6/site-packages/django/db/models/base.py", line 501, in __init__
awx_1        |     raise TypeError("%s() got an unexpected keyword argument '%s'" % (cls.__name__, kwarg))
awx_1        | TypeError: InventoryUpdateEvent() got an unexpected keyword argument 'workflow_job_id'
awx_1        | 2019-10-04 16:26:53,570 ERROR    awx.main.commands.run_callback_receiver Callback Task Processor Raised Exception: TypeError("InventoryUpdateEvent() got an unexpected keyword argument 'workflow_job_id'",)

# Fixed code
def create_from_data(cls, **kwargs):
    # Convert the datetime for the event's creation
    # appropriately, and include a time zone for it.
    #
    # In the event of any issue, throw it out, and Django will just save
    # the current time.
    try:
        if not isinstance(kwargs["created"], datetime.datetime):
            kwargs["created"] = parse_datetime(kwargs["created"])
        if not kwargs["created"].tzinfo:
            kwargs["created"] = kwargs["created"].replace(tzinfo=utc)
    except (KeyError, ValueError):
        kwargs.pop("created", None)

    sanitize_event_keys(kwargs, cls.VALID_KEYS)
    kwargs.pop("workflow_job_id", None)
    event = cls.objects.create(**kwargs)
    if isinstance(event, AdHocCommandEvent):
        analytics_logger.info(
            "Event data saved.", extra=dict(python_objects=dict(job_event=event))
        )
    return event