From a90aa2cb2e69b5f722ee8cf390787e1443ab10d0 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 4 Sep 2022 00:52:41 +0200 Subject: [PATCH] Make sure that a webhook function never returns a null response --- platypush/backend/http/app/routes/hook.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platypush/backend/http/app/routes/hook.py b/platypush/backend/http/app/routes/hook.py index 5d9b420cc..e5d3de408 100644 --- a/platypush/backend/http/app/routes/hook.py +++ b/platypush/backend/http/app/routes/hook.py @@ -60,7 +60,7 @@ def hook_route(hook_name): try: send_message(event) - rs = make_response(json.dumps({'status': 'ok', **event_args})) + rs = default_rs = make_response(json.dumps({'status': 'ok', **event_args})) headers = {} status_code = 200 @@ -78,6 +78,10 @@ def hook_route(hook_name): status_code = rs.get('___code___', status_code) rs = rs['___data___'] + if rs is None: + rs = default_rs + headers = {'Content-Type': 'application/json'} + rs = make_response(rs) else: headers = {'Content-Type': 'application/json'}