mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
webhooks: Log unexpected webhook events separately.
This change serves to declutter webhook-errors.log, which is filled with too many UnexpectedWebhookEventType exceptions. Keeping UnexpectedWebhookEventType in zerver/lib/webhooks/common.py led to a cyclic import when we tried to import the exception in zerver/decorators.py, so this commit also moves this exception to another appropriate module. Note that our webhooks still import this exception via zerver/lib/webhooks/common.py.
This commit is contained in:
@@ -8,7 +8,7 @@ from typing import Optional, Dict, Union, Any, Callable
|
||||
from zerver.lib.actions import check_send_stream_message, \
|
||||
check_send_private_message, send_rate_limited_pm_notification_to_bot_owner
|
||||
from zerver.lib.exceptions import StreamDoesNotExistError, JsonableError, \
|
||||
ErrorCode
|
||||
ErrorCode, UnexpectedWebhookEventType
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.send_email import FromAddress
|
||||
from zerver.models import UserProfile
|
||||
@@ -39,18 +39,6 @@ def notify_bot_owner_about_invalid_json(user_profile: UserProfile,
|
||||
INVALID_JSON_MESSAGE.format(webhook_name=webhook_client_name).strip()
|
||||
)
|
||||
|
||||
class UnexpectedWebhookEventType(JsonableError):
|
||||
code = ErrorCode.UNEXPECTED_WEBHOOK_EVENT_TYPE
|
||||
data_fields = ['webhook_name', 'event_type']
|
||||
|
||||
def __init__(self, webhook_name: str, event_type: Optional[str]) -> None:
|
||||
self.webhook_name = webhook_name
|
||||
self.event_type = event_type
|
||||
|
||||
@staticmethod
|
||||
def msg_format() -> str:
|
||||
return _("The '{event_type}' event isn't currently supported by the {webhook_name} webhook")
|
||||
|
||||
class MissingHTTPEventHeader(JsonableError):
|
||||
code = ErrorCode.MISSING_HTTP_EVENT_HEADER
|
||||
data_fields = ['header']
|
||||
|
||||
Reference in New Issue
Block a user