From c2fcfc087a375c75b100eab0c3d06dc09072b2e1 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 29 Jan 2019 20:06:27 +0000 Subject: [PATCH] bugdown: Include message id in exceptions. --- zerver/lib/bugdown/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index 13d1bbcb5e..0f5ce3159f 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -2139,6 +2139,11 @@ def do_convert(content: str, else: realm_filters_key = message_realm.id + if message and hasattr(message, 'id') and message.id: + logging_message_id = 'id# ' + str(message.id) + else: + logging_message_id = 'unknown' + if message is not None and message_realm is not None: if message_realm.is_zephyr_mirror_realm: if message.sending_client.name == "zephyr_mirror": @@ -2213,16 +2218,16 @@ def do_convert(content: str, # rest of the codebase from any bugs where we end up rendering # something huge. if len(rendered_content) > MAX_MESSAGE_LENGTH * 10: - raise BugdownRenderingException('Rendered content exceeds %s characters' % - (MAX_MESSAGE_LENGTH * 10,)) + raise BugdownRenderingException('Rendered content exceeds %s characters (message %s)' % + (MAX_MESSAGE_LENGTH * 10, logging_message_id)) return rendered_content except Exception: cleaned = privacy_clean_markdown(content) # NOTE: Don't change this message without also changing the # logic in logging_handlers.py or we can create recursive # exceptions. - exception_message = ('Exception in Markdown parser: %sInput (sanitized) was: %s' - % (traceback.format_exc(), cleaned)) + exception_message = ('Exception in Markdown parser: %sInput (sanitized) was: %s\n (message %s)' + % (traceback.format_exc(), cleaned, logging_message_id)) bugdown_logger.exception(exception_message) raise BugdownRenderingException()