# Buggy code
def __init__(
    self,
    *,
    trigger_dag_id: str,
    conf: Optional[Dict] = None,
    execution_date: Optional[Union[str, datetime.datetime]] = None,
    reset_dag_run: bool = False,
    wait_for_completion: bool = False,
    poke_interval: int = 60,
    allowed_states: Optional[List] = None,
    failed_states: Optional[List] = None,
    **kwargs,
) -> None:
    super().__init__(**kwargs)
    self.trigger_dag_id = trigger_dag_id
    self.conf = conf
    self.reset_dag_run = reset_dag_run
    self.wait_for_completion = wait_for_completion
    self.poke_interval = poke_interval
    self.allowed_states = allowed_states or [State.SUCCESS]
    self.failed_states = failed_states or [State.FAILED]

    if not isinstance(execution_date, (str, datetime.datetime, type(None))):
        raise TypeError(
            "Expected str or datetime.datetime type for execution_date.Got {}".format(
                type(execution_date)
            )
        )

    self.execution_date: Optional[datetime.datetime] = execution_date  # type: ignore


# Traceback (TypeError)
Ooops!
Something bad has happened.
Please consider letting us know by creating a bug report using GitHub.

Python version: 3.6.9
Airflow version: 2.0.0
Node: henry-Inspiron-5566
-------------------------------------------------------------------------------
Traceback (most recent call last):
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/airflow/www/auth.py", line 34, in decorated
return func(*args, **kwargs)
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/airflow/www/decorators.py", line 97, in view_func
return f(*args, **kwargs)
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/airflow/www/decorators.py", line 60, in wrapper
return f(*args, **kwargs)
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/airflow/www/views.py", line 1997, in tree
data = htmlsafe_json_dumps(data, separators=(',', ':'))
File "/home/henry/Envs2/airflow3/lib/python3.6/site-packages/jinja2/utils.py", line 614, in htmlsafe_json_dumps
dumper(obj, **kwargs)
File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.6/json/encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'datetime' is not JSON serializable

# Fixed code
def __init__(
    self,
    *,
    trigger_dag_id: str,
    conf: Optional[Dict] = None,
    execution_date: Optional[Union[str, datetime.datetime]] = None,
    reset_dag_run: bool = False,
    wait_for_completion: bool = False,
    poke_interval: int = 60,
    allowed_states: Optional[List] = None,
    failed_states: Optional[List] = None,
    **kwargs,
) -> None:
    super().__init__(**kwargs)
    self.trigger_dag_id = trigger_dag_id
    self.conf = conf
    self.reset_dag_run = reset_dag_run
    self.wait_for_completion = wait_for_completion
    self.poke_interval = poke_interval
    self.allowed_states = allowed_states or [State.SUCCESS]
    self.failed_states = failed_states or [State.FAILED]

    if not isinstance(execution_date, (str, datetime.datetime, type(None))):
        raise TypeError(
            "Expected str or datetime.datetime type for execution_date.Got {}".format(
                type(execution_date)
            )
        )

    self.execution_date: Optional[datetime.datetime] = execution_date  # type: ignore

    try:
        json.dumps(self.conf)
    except TypeError:
        raise AirflowException("conf parameter should be JSON Serializable")