From 47b9fa551d8c78003eb3ed6092341a17c3ff36d7 Mon Sep 17 00:00:00 2001 From: cmuoh-smar <93012050+cmuoh-smar@users.noreply.github.com> Date: Wed, 5 Jul 2023 09:56:25 -0400 Subject: [PATCH] fix KeyError when 'body' not in event --- flask_lambda.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flask_lambda.py b/flask_lambda.py index 9de6d76..b041b0b 100644 --- a/flask_lambda.py +++ b/flask_lambda.py @@ -32,6 +32,11 @@ def make_environ(event): environ = {} print('event', event) + + # fix issue where body is not present in the event + if 'body' not in event: + event['body'] = None + # key might be there but set to None headers = event.get('headers', {}) or {} for hdr_name, hdr_value in headers.items():