From 3be6b0e2fece91d89f7ea9020b06b4897090ed64 Mon Sep 17 00:00:00 2001 From: Jochen Kupperschmidt Date: Fri, 6 May 2022 02:48:59 +0200 Subject: [PATCH] Return 400 on missing/empty JSON payload --- src/weitersager/http.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/weitersager/http.py b/src/weitersager/http.py index c8bebc9..4e85d9b 100644 --- a/src/weitersager/http.py +++ b/src/weitersager/http.py @@ -66,8 +66,11 @@ def on_root(self, request): if not request.is_json: abort(HTTPStatus.UNSUPPORTED_MEDIA_TYPE) + payload = request.json + if payload is None: + abort(HTTPStatus.BAD_REQUEST) + try: - payload = request.json channel = payload['channel'] text = payload['text'] except KeyError: