Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
decorator: Stop stringifying exceptions unnecessarily.
Alex Vandiver8a6f96acad87
diff --git a/zerver/decorator.py b/zerver/decorator.pyindex 5394e39479e..4616d19494e 100644--- a/zerver/decorator.py+++ b/zerver/decorator.py@@ -313,11 +313,11 @@ def log_unsupported_webhook_event(request: HttpRequest, summary: str) -> None:def log_exception_to_webhook_logger(request: HttpRequest, err: Exception) -> None:extra = {"request": request}if isinstance(err, AnomalousWebhookPayloadError):- webhook_anomalous_payloads_logger.exception(str(err), stack_info=True, extra=extra)+ webhook_anomalous_payloads_logger.exception(err, stack_info=True, extra=extra)elif isinstance(err, UnsupportedWebhookEventTypeError):- webhook_unsupported_events_logger.exception(str(err), stack_info=True, extra=extra)+ webhook_unsupported_events_logger.exception(err, stack_info=True, extra=extra)else:- webhook_logger.exception(str(err), stack_info=True, extra=extra)+ webhook_logger.exception(err, stack_info=True, extra=extra)def full_webhook_client_name(raw_client_name: Optional[str] = None) -> Optional[str]:diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.pyindex 53c6db2c46a..5a2cdcd9cad 100644--- a/zerver/tests/test_decorators.py+++ b/zerver/tests/test_decorators.py@@ -414,8 +414,12 @@ class DecoratorLoggingTestCase(ZulipTestCase):with self.assertRaisesRegex(UnsupportedWebhookEventTypeError, exception_msg):my_webhook_raises_exception(request)- mock_exception.assert_called_with(- exception_msg, stack_info=True, extra={"request": request}+ mock_exception.assert_called_once()+ self.assertIsInstance(mock_exception.call_args.args[0], UnsupportedWebhookEventTypeError)+ self.assertEqual(mock_exception.call_args.args[0].event_type, "test_event")+ self.assertEqual(mock_exception.call_args.args[0].msg, exception_msg)+ self.assertEqual(+ mock_exception.call_args.kwargs, {"stack_info": True, "extra": {"request": request}})def test_authenticated_rest_api_view_with_non_webhook_view(self) -> None: