From 869f96e31be0885f79cf32f5fc88a0fdedfe0fa2 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 11 Oct 2023 18:51:41 +0000 Subject: [PATCH] decorator: Drop the stack_info on most WebhookErrors. `stack_info` shows the stack between where the error was raised and where it was captured -- which is not interesting when we intentionally raised it, and know where it will be captured. Omit the `stack_info` when it will just fill the logs with uninteresting data. --- zerver/decorator.py | 7 +++++-- zerver/tests/test_decorators.py | 4 +--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/zerver/decorator.py b/zerver/decorator.py index abb2e209d7..3074d19429 100644 --- a/zerver/decorator.py +++ b/zerver/decorator.py @@ -312,10 +312,13 @@ def log_unsupported_webhook_event(request: HttpRequest, summary: str) -> None: def log_exception_to_webhook_logger(request: HttpRequest, err: Exception) -> None: extra = {"request": request} + # We intentionally omit the stack_info for these events, where + # they are intentionally raised, and the stack_info between that + # point and this one is not interesting. if isinstance(err, AnomalousWebhookPayloadError): - webhook_anomalous_payloads_logger.exception(err, stack_info=True, extra=extra) + webhook_anomalous_payloads_logger.exception(err, extra=extra) elif isinstance(err, UnsupportedWebhookEventTypeError): - webhook_unsupported_events_logger.exception(err, stack_info=True, extra=extra) + webhook_unsupported_events_logger.exception(err, extra=extra) else: webhook_logger.exception(err, stack_info=True, extra=extra) diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index 5a2cdcd9ca..d81d707016 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -418,9 +418,7 @@ class DecoratorLoggingTestCase(ZulipTestCase): 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}} - ) + self.assertEqual(mock_exception.call_args.kwargs, {"extra": {"request": request}}) def test_authenticated_rest_api_view_with_non_webhook_view(self) -> None: @authenticated_rest_api_view()