# Buggy code
def __init__(
    self,
    entry_points,
    states,
    fallbacks,
    allow_reentry=False,
    per_chat=True,
    per_user=True,
    per_message=False,
    conversation_timeout=None,
    name=None,
    persistent=False,
    map_to_parent=None,
):
    self._entry_points = entry_points
    self._states = states
    self._fallbacks = fallbacks

    self._allow_reentry = allow_reentry
    self._per_user = per_user
    self._per_chat = per_chat
    self._per_message = per_message
    self._conversation_timeout = conversation_timeout
    self._name = name
    if persistent and not self.name:
        raise ValueError("Conversations can't be persistent when handler is unnamed.")
    self.persistent = persistent
    self._persistence = None
    """:obj:`telegram.ext.BasePersistence`: The persistence used to store conversations.
        Set by dispatcher"""
    self._map_to_parent = map_to_parent

    self.timeout_jobs = dict()
    self._timeout_jobs_lock = Lock()
    self._conversations = dict()
    self._conversations_lock = Lock()

    self.logger = logging.getLogger(__name__)

    if not any((self.per_user, self.per_chat, self.per_message)):
        raise ValueError(
            "'per_user', 'per_chat' and 'per_message' can't all be 'False'"
        )

    if self.per_message and not self.per_chat:
        warnings.warn(
            "If 'per_message=True' is used, 'per_chat=True' should also be used, "
            "since message IDs are not globally unique."
        )

    all_handlers = list()
    all_handlers.extend(entry_points)
    all_handlers.extend(fallbacks)

    for state_handlers in states.values():
        all_handlers.extend(state_handlers)

    if self.per_message:
        for handler in all_handlers:
            if not isinstance(handler, CallbackQueryHandler):
                warnings.warn(
                    "If 'per_message=True', all entry points and state handlers"
                    " must be 'CallbackQueryHandler', since no other handlers "
                    "have a message context."
                )
                break
    else:
        for handler in all_handlers:
            if isinstance(handler, CallbackQueryHandler):
                warnings.warn(
                    "If 'per_message=False', 'CallbackQueryHandler' will not be "
                    "tracked for every message."
                )
                break

    if self.per_chat:
        for handler in all_handlers:
            if isinstance(handler, (InlineQueryHandler, ChosenInlineResultHandler)):
                warnings.warn(
                    "If 'per_chat=True', 'InlineQueryHandler' can not be used, "
                    "since inline queries have no chat context."
                )
                break


# Traceback (telegram.error.BadRequest)
<project_path>/venv/bin/python <project_path>/issue.py
2017-06-20 23:24:11,743 - __main__ - INFO - /start
2017-06-20 23:24:11,906 - telegram.ext.dispatcher - WARNING - A TelegramError was raised while processing the Update.
2017-06-20 23:24:11,907 - __main__ - ERROR - Boom!
2017-06-20 23:24:11,907 - __main__ - INFO - /async_start
2017-06-20 23:24:12,188 - telegram.utils.promise - ERROR - An uncaught error was raised while running the promise
Traceback (most recent call last):
File "<project_path>/venv/src/python-telegram-bot/telegram/utils/promise.py", line 42, in run
self._result = self.pooled_function(*self.args, **self.kwargs)
File "<project_path>/issue.py", line 25, in action_async_start
update.message.reply_text(msg, parse_mode=ParseMode.HTML)
File "<project_path>/venv/src/python-telegram-bot/telegram/message.py", line 340, in reply_text
return self.bot.send_message(self.chat_id, *args, **kwargs)
File "<project_path>/venv/src/python-telegram-bot/telegram/bot.py", line 125, in decorator
result = func(self, *args, **kwargs)
File "<project_path>/venv/src/python-telegram-bot/telegram/bot.py", line 158, in decorator
return Bot._message_wrapper(self, url, data, *args, **kwargs)
File "<project_path>/venv/src/python-telegram-bot/telegram/bot.py", line 146, in _message_wrapper
result = self._request.post(url, data, timeout=kwargs.get('timeout'))
File "<project_path>/venv/src/python-telegram-bot/telegram/utils/request.py", line 252, in post
**urlopen_kwargs)
File "<project_path>/venv/src/python-telegram-bot/telegram/utils/request.py", line 194, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Can't parse entities in message text: unsupported start tag "invalid_tag" at byte offset 0

Process finished with exit code 0

# Fixed code
def __init__(
    self,
    entry_points,
    states,
    fallbacks,
    allow_reentry=False,
    per_chat=True,
    per_user=True,
    per_message=False,
    conversation_timeout=None,
    name=None,
    persistent=False,
    map_to_parent=None,
):
    self.run_async = False

    self._entry_points = entry_points
    self._states = states
    self._fallbacks = fallbacks

    self._allow_reentry = allow_reentry
    self._per_user = per_user
    self._per_chat = per_chat
    self._per_message = per_message
    self._conversation_timeout = conversation_timeout
    self._name = name
    if persistent and not self.name:
        raise ValueError("Conversations can't be persistent when handler is unnamed.")
    self.persistent = persistent
    self._persistence = None
    """:obj:`telegram.ext.BasePersistence`: The persistence used to store conversations.
        Set by dispatcher"""
    self._map_to_parent = map_to_parent

    self.timeout_jobs = dict()
    self._timeout_jobs_lock = Lock()
    self._conversations = dict()
    self._conversations_lock = Lock()

    self.logger = logging.getLogger(__name__)

    if not any((self.per_user, self.per_chat, self.per_message)):
        raise ValueError(
            "'per_user', 'per_chat' and 'per_message' can't all be 'False'"
        )

    if self.per_message and not self.per_chat:
        warnings.warn(
            "If 'per_message=True' is used, 'per_chat=True' should also be used, "
            "since message IDs are not globally unique."
        )

    all_handlers = list()
    all_handlers.extend(entry_points)
    all_handlers.extend(fallbacks)

    for state_handlers in states.values():
        all_handlers.extend(state_handlers)

    if self.per_message:
        for handler in all_handlers:
            if not isinstance(handler, CallbackQueryHandler):
                warnings.warn(
                    "If 'per_message=True', all entry points and state handlers"
                    " must be 'CallbackQueryHandler', since no other handlers "
                    "have a message context."
                )
                break
    else:
        for handler in all_handlers:
            if isinstance(handler, CallbackQueryHandler):
                warnings.warn(
                    "If 'per_message=False', 'CallbackQueryHandler' will not be "
                    "tracked for every message."
                )
                break

    if self.per_chat:
        for handler in all_handlers:
            if isinstance(handler, (InlineQueryHandler, ChosenInlineResultHandler)):
                warnings.warn(
                    "If 'per_chat=True', 'InlineQueryHandler' can not be used, "
                    "since inline queries have no chat context."
                )
                break