Skip to content

Commit def67bd

Browse files
committed
fix: report payload parsing failure and return 204 instead of 400
1 parent 67b23af commit def67bd

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

topgg/webhooks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,12 @@ async def handler(request: web.Request) -> web.Response:
209209
return web.json_response({'error': 'Invalid request body'}, status=422)
210210
except web.HTTPRequestEntityTooLarge: # pragma: nocover
211211
return web.json_response({'error': 'Request body too large'}, status=413)
212-
except Exception:
213-
return web.json_response({'error': 'Unable to parse request body'}, status=400)
212+
except Exception as err: # pragma: nocover
213+
warnings.warn(
214+
f'Unable to parse Top.gg webhook payload. Please report this bug to the SDK maintainers.\nCause: {err}\n--- BEGIN BODY DUMP ---\n{body}\n--- END BODY DUMP ---'
215+
)
216+
217+
return web.Response(status=204)
214218

215219
signature = request.headers.get('x-topgg-signature')
216220
trace = request.headers.get('x-topgg-trace')

0 commit comments

Comments
 (0)