Skip to content

Commit

Permalink
Log failed webhook attempts to stderr in GitHub Webhook Filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Apr 1, 2024
1 parent 346d570 commit 229d8fb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pydis_site/apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,21 @@ def post(self, request: Request, *, webhook_id: str, webhook_token: str) -> Resp
webhook_id, webhook_token, request.data, dict(request.headers),
)

body_decoded = body.decode("utf-8")

if (
not (status.HTTP_200_OK <= response_status < status.HTTP_300_MULTIPLE_CHOICES)
and response_status != status.HTTP_429_TOO_MANY_REQUESTS
):
self.logger.warning(
"Failed to send GitHub webhook to Discord. Response code %d, body: %s",
response_status,
body_decoded,
)

response_body = {
"original_status": response_status,
"data": body.decode("utf-8"),
"data": body_decoded,
"headers": headers,
}

Expand Down

0 comments on commit 229d8fb

Please sign in to comment.