# Buggy code
def concat_url(base: Text, subpath: Optional[Text]) -> Text:
    """Append a subpath to a base url.

    Strips leading slashes from the subpath if necessary. This behaves
    differently than `urlparse.urljoin` and will not treat the subpath
    as a base url if it starts with `/` but will always append it to the
    `base`."""

    if not subpath:
        return base

    url = base
    if not base.endswith("/"):
        url += "/"
    if subpath.startswith("/"):
        subpath = subpath[1:]
    return url + subpath


# Traceback (rasa.utils.endpoints.ClientResponseError)
What is the next action of the bot?  0.00 validate_inputs
Thanks! The bot will now run validate_inputs.

2019-05-29 14:53:46 DEBUG    rasa.core.tracker_store  - Recreating tracker for id '5cf18e01f02242af875ebc33d557cda0'
2019-05-29 14:53:46 DEBUG    rasa.core.tracker_store  - Recreating tracker for id '5cf18e01f02242af875ebc33d557cda0'
2019-05-29 14:53:46 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'validate_inputs'.
2019-05-29 14:53:46 ERROR    rasa.core.processor  - Encountered an exception while running action 'validate_inputs'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
2019-05-29 14:53:46 DEBUG    rasa.core.processor  - Failed to execute custom action.
Traceback (most recent call last):
File "/home/sfrplindia1/Work/SantaFe/Raghuram/chatbots/rasa_15/lib/python3.6/site-packages/rasa/core/actions/action.py", line 410, in run
json=json_body, method="post", timeout=DEFAULT_REQUEST_TIMEOUT
File "/usr/lib/python3.6/asyncio/coroutines.py", line 110, in __next__
return self.gen.send(None)
File "/home/sfrplindia1/Work/SantaFe/Raghuram/chatbots/rasa_15/lib/python3.6/site-packages/rasa/utils/endpoints.py", line 140, in request
resp.status, resp.reason, await resp.content.read()
rasa.utils.endpoints.ClientResponseError: 404, NOT FOUND, body='b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>404 Not Found</title>\n<h1>Not Found</h1>\n<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>\n''

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/sfrplindia1/Work/SantaFe/Raghuram/chatbots/rasa_15/lib/python3.6/site-packages/rasa/core/processor.py", line 431, in _run_action
events = await action.run(output_channel, nlg, tracker, self.domain)
File "/usr/lib/python3.6/asyncio/coroutines.py", line 110, in __next__
return self.gen.send(None)
File "/home/sfrplindia1/Work/SantaFe/Raghuram/chatbots/rasa_15/lib/python3.6/site-packages/rasa/core/actions/action.py", line 432, in run
raise Exception("Failed to execute custom action.") from e
Exception: Failed to execute custom action.
2019-05-29 14:53:46 DEBUG    rasa.core.processor  - Action 'validate_inputs' ended with events '[]'

# Fixed code
def concat_url(base: Text, subpath: Optional[Text]) -> Text:
    """Append a subpath to a base url.

    Strips leading slashes from the subpath if necessary. This behaves
    differently than `urlparse.urljoin` and will not treat the subpath
    as a base url if it starts with `/` but will always append it to the
    `base`."""

    if not subpath:
        return base.rstrip("/")

    url = base
    if not base.endswith("/"):
        url += "/"
    if subpath.startswith("/"):
        subpath = subpath[1:]
    return url + subpath