Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
integrations: Prevent logging of MissingHTTPEventHeaderError.
theofficialvedantjoshicb07605e5297
diff --git a/zerver/decorator.py b/zerver/decorator.pyindex 0733210bd0d..d66f4a0eac5 100644--- a/zerver/decorator.py+++ b/zerver/decorator.py@@ -52,7 +52,10 @@ from zerver.lib.timestamp import datetime_to_timestamp, timestamp_to_datetimefrom zerver.lib.typed_endpoint import typed_endpointfrom zerver.lib.users import is_2fa_verifiedfrom zerver.lib.utils import has_api_key_format-from zerver.lib.webhooks.common import notify_bot_owner_about_invalid_json+from zerver.lib.webhooks.common import (+ MissingHTTPEventHeaderError,+ notify_bot_owner_about_invalid_json,+)from zerver.models import UserProfilefrom zerver.models.clients import get_clientfrom zerver.models.users import get_user_profile_by_api_key@@ -341,6 +344,12 @@ 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 deliberately skip logging this client error, as it results from a malformed request+ # and doesn't indicate an issue on our end.+ if isinstance(err, MissingHTTPEventHeaderError):+ return+# 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.diff --git a/zerver/tests/test_webhooks_common.py b/zerver/tests/test_webhooks_common.pyindex 19a3032f568..a9bc8a69245 100644--- a/zerver/tests/test_webhooks_common.py+++ b/zerver/tests/test_webhooks_common.py@@ -223,13 +223,12 @@ class MissingEventHeaderTestCase(WebhookTestCase):# an actual webhook, instead of just making a mockdef test_missing_event_header(self) -> None:self.subscribe(self.test_user, self.CHANNEL_NAME)- with self.assertLogs("zulip.zerver.webhooks.anomalous", level="INFO") as webhook_logs:+ with self.assertNoLogs("zulip.zerver.webhooks.anomalous", level="INFO"):result = self.client_post(self.url,self.get_body("ticket_state_changed"),content_type="application/x-www-form-urlencoded",)- self.assertTrue("Missing the HTTP event header 'X-Groove-Event'" in webhook_logs.output[0])self.assert_json_error(result, "Missing the HTTP event header 'X-Groove-Event'")realm = get_realm("zulip")