mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 10:33:54 +00:00
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.
This commit is contained in:
committed by
Tim Abbott
parent
05d8c9d49e
commit
869f96e31b
@@ -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)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user