mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
integrations: Prevent logging of MissingHTTPEventHeaderError.
Fixes #34623.
This commit is contained in:
committed by
Tim Abbott
parent
fa03c42009
commit
cb07605e52
@@ -52,7 +52,10 @@ from zerver.lib.timestamp import datetime_to_timestamp, timestamp_to_datetime
|
||||
from zerver.lib.typed_endpoint import typed_endpoint
|
||||
from zerver.lib.users import is_2fa_verified
|
||||
from 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 UserProfile
|
||||
from zerver.models.clients import get_client
|
||||
from 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.
|
||||
|
@@ -223,13 +223,12 @@ class MissingEventHeaderTestCase(WebhookTestCase):
|
||||
# an actual webhook, instead of just making a mock
|
||||
def 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")
|
||||
|
Reference in New Issue
Block a user