webhooks: Use 200 status code for unknown events.

Because the third party might not be expecting a 400 from our
webhooks, we now instead use 200 status code for unknown events,
while sending back the error to Sentry. Because it is no longer an error
response, the response type should now be "success".

Fixes #24721.
This commit is contained in:
Zixuan James Li
2023-04-04 01:09:30 -04:00
committed by Tim Abbott
parent 2e4f7f6336
commit 84723654c8
9 changed files with 52 additions and 10 deletions

View File

@@ -370,6 +370,7 @@ class UnsupportedWebhookEventTypeError(WebhookError):
"""
code = ErrorCode.UNSUPPORTED_WEBHOOK_EVENT_TYPE
http_status_code = 200
data_fields = ["webhook_name", "event_type"]
def __init__(self, event_type: Optional[str]) -> None:
@@ -378,7 +379,9 @@ class UnsupportedWebhookEventTypeError(WebhookError):
@staticmethod
def msg_format() -> str:
return _("The '{event_type}' event isn't currently supported by the {webhook_name} webhook")
return _(
"The '{event_type}' event isn't currently supported by the {webhook_name} webhook; ignoring"
)
class AnomalousWebhookPayloadError(WebhookError):