mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
webhook_decorator: Support notifying bot owner on invalid JSON.
Our webhook-errors.log file is riddled with exceptions that are logged when a webhook is incorrectly configured to send data in a non-JSON format. To avoid this, api_key_only_webhook_view now supports an additional argument, notify_bot_owner_on_invalid_json. This argument, when True, will send a PM notification to the bot's owner notifying them of the configuration issue.
This commit is contained in:
@@ -28,6 +28,7 @@ class ErrorCode(AbstractEnum):
|
||||
BAD_REQUEST = () # Generic name, from the name of HTTP 400.
|
||||
REQUEST_VARIABLE_MISSING = ()
|
||||
REQUEST_VARIABLE_INVALID = ()
|
||||
INVALID_JSON = ()
|
||||
BAD_IMAGE = ()
|
||||
REALM_UPLOAD_QUOTA = ()
|
||||
BAD_NARROW = ()
|
||||
@@ -142,5 +143,12 @@ class RateLimited(PermissionDenied):
|
||||
def __init__(self, msg: str="") -> None:
|
||||
super().__init__(msg)
|
||||
|
||||
class InvalidJSONError(JsonableError):
|
||||
code = ErrorCode.INVALID_JSON
|
||||
|
||||
@staticmethod
|
||||
def msg_format() -> str:
|
||||
return _("Malformed JSON")
|
||||
|
||||
class BugdownRenderingException(Exception):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user