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.

(cherry picked from commit 84723654c8)
This commit is contained in:
Zixuan James Li
2023-04-04 01:09:30 -04:00
committed by Alex Vandiver
parent 61b5577cf4
commit ec8a284ad5
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):