diff --git a/chat/src/event_config.py b/chat/src/event_config.py index 7590c842..5c7762b3 100644 --- a/chat/src/event_config.py +++ b/chat/src/event_config.py @@ -122,7 +122,7 @@ def _get_attributes(self): attributes = [ item for item in self._get_request_attributes() - if item not in [self._get_text_key(), "source"] + if item not in [self._get_text_key(), "source", "full_text"] ] return attributes diff --git a/chat/src/handlers/chat.py b/chat/src/handlers/chat.py index 46b53b99..aa19ff79 100644 --- a/chat/src/handlers/chat.py +++ b/chat/src/handlers/chat.py @@ -2,7 +2,6 @@ from event_config import EventConfig from helpers.response import prepare_response - def handler(event, _context): try: config = EventConfig(event) @@ -21,5 +20,10 @@ def handler(event, _context): final_response = prepare_response(config) config.socket.send(final_response) return {"statusCode": 200} + except Exception as err: - raise err \ No newline at end of file + if err.__class__.__name__ == "PayloadTooLargeException": + config.socket.send({"type": "error", "message": "Payload too large"}) + return {"statusCode": 413, "body": "Payload too large"} + else: + raise err