diff --git a/lib/tfw/components/process_managing_event_handler.py b/lib/tfw/components/process_managing_event_handler.py index 6fcc248..ab63607 100644 --- a/lib/tfw/components/process_managing_event_handler.py +++ b/lib/tfw/components/process_managing_event_handler.py @@ -36,6 +36,9 @@ class ProcessManagingEventHandler(TriggerlessEventHandler): @_with_monitor_paused def handle_event(self, key, data_json): - data = data_json['data'] - self.processmanager(data['command'], data['process_name']) - self.uplink.send(self.key, {'data': {'process_name': data['process_name']}}) + try: + data = data_json['data'] + self.processmanager(data['command'], data['process_name']) + self.uplink.send(self.key, {'data': {'process_name': data['process_name']}}) + except KeyError: + log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json)) diff --git a/lib/tfw/components/source_code_event_handler.py b/lib/tfw/components/source_code_event_handler.py index dd26072..003264a 100644 --- a/lib/tfw/components/source_code_event_handler.py +++ b/lib/tfw/components/source_code_event_handler.py @@ -84,10 +84,13 @@ class SourceCodeEventHandler(TriggerlessEventHandler): data['files'] = self.filemanager.files def handle_event(self, key, data_json): - data = data_json['data'] - data_json['data'] = self.commands[data['command']](data) - self.attach_fileinfo(data) - return data_json + try: + data = data_json['data'] + data_json['data'] = self.commands[data['command']](data) + self.attach_fileinfo(data) + return data_json + except KeyError: + log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json)) def cleanup(self): self.monitor.stop() diff --git a/lib/tfw/components/terminado_event_handler.py b/lib/tfw/components/terminado_event_handler.py index 4a8f98a..649f823 100644 --- a/lib/tfw/components/terminado_event_handler.py +++ b/lib/tfw/components/terminado_event_handler.py @@ -23,8 +23,11 @@ class TerminadoEventHandler(TriggerlessEventHandler): def handle_event(self, key, data_json): log.debug('TerminadoEventHandler received event: {}'.format(data_json)) - data_json['data'] = self.commands[data_json['data']['command']](data_json['data']) - return data_json + try: + data_json['data'] = self.commands[data_json['data']['command']](data_json['data']) + return data_json + except KeyError: + log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json)) def write(self, data): self.terminado_server.pty.write(data['shellcmd'])