# Buggy code
def handle_channels(
    self,
    channels: List[InputChannel],
    http_port: int = constants.DEFAULT_SERVER_PORT,
    route: Text = "/webhooks/",
    cors=None,
) -> Sanic:
    """Start a webserver attaching the input channels and handling msgs."""

    from rasa.core import run

    logger.warning(
        "DEPRECATION warning: Using `handle_channels` is deprecated. "
        "Please use `rasa.run(...)` or see "
        "`rasa.core.run.configure_app(...)` if you want to implement "
        "this on a more detailed level."
    )

    app = run.configure_app(channels, cors, None, enable_api=False, route=route)

    app.agent = self

    update_sanic_log_level()

    app.run(
        host="0.0.0.0",
        port=http_port,
        backlog=int(os.environ.get("SANIC_BACKLOG", "100")),
    )

    # this might seem unnecessary (as run does not return until the server
    # is killed) - but we use it for tests where we mock `.run` to directly
    # return and need the app to inspect if we created a properly
    # configured server
    return app


# Traceback (TypeError)
Exception occurred in one of response middleware handlers
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sanic/app.py", line 985, in handle_request
request, response
File "/usr/local/lib/python3.6/site-packages/spf/framework.py", line 579, in _run_response_middleware
_response = await _response
File "/usr/local/lib/python3.6/site-packages/sanic_cors/extension.py", line 267, in unapplied_cors_response_middleware
set_cors_headers(req, resp, context, res_options)
File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 254, in set_cors_headers
headers_to_set = get_cors_headers(options, req.headers, req.method)
File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 174, in get_cors_headers
origins_to_set = get_cors_origins(options, request_headers.get('Origin'))
File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 149, in get_cors_origins
return sorted([o for o in origins if not probably_regex(o)])
File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 149, in <listcomp>
return sorted([o for o in origins if not probably_regex(o)])
File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 273, in probably_regex
return any((c in maybe_regex for c in common_regex_chars))
File "/usr/local/lib/python3.6/site-packages/sanic_cors/core.py", line 273, in <genexpr>
return any((c in maybe_regex for c in common_regex_chars))
TypeError: argument of type 'NoneType' is not iterable

# Fixed code
def handle_channels(
    self,
    channels: List[InputChannel],
    http_port: int = constants.DEFAULT_SERVER_PORT,
    route: Text = "/webhooks/",
    cors: Union[Text, List[Text], None] = None,
) -> Sanic:
    """Start a webserver attaching the input channels and handling msgs."""

    from rasa.core import run

    logger.warning(
        "DEPRECATION warning: Using `handle_channels` is deprecated. "
        "Please use `rasa.run(...)` or see "
        "`rasa.core.run.configure_app(...)` if you want to implement "
        "this on a more detailed level."
    )

    app = run.configure_app(channels, cors, None, enable_api=False, route=route)

    app.agent = self

    update_sanic_log_level()

    app.run(
        host="0.0.0.0",
        port=http_port,
        backlog=int(os.environ.get("SANIC_BACKLOG", "100")),
    )

    # this might seem unnecessary (as run does not return until the server
    # is killed) - but we use it for tests where we mock `.run` to directly
    # return and need the app to inspect if we created a properly
    # configured server
    return app