Skip to content

Commit

Permalink
Return 400 on missing/empty JSON payload
Browse files Browse the repository at this point in the history
  • Loading branch information
homeworkprod committed May 6, 2022
1 parent c7e4b0b commit 3be6b0e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/weitersager/http.py
Expand Up @@ -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:
Expand Down

0 comments on commit 3be6b0e

Please sign in to comment.