From 09173235920efedbdb9eea9693b2d29a7ec08d3c Mon Sep 17 00:00:00 2001 From: Peter Van Bouwel Date: Wed, 8 Sep 2021 13:35:59 +0200 Subject: [PATCH] When no audit log is available an IndexError is thrown which is not clear for all users. This minor change will log a critical error with an explanation why it errors out. --- src/SimpleReplay/extract.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/SimpleReplay/extract.py b/src/SimpleReplay/extract.py index c55857cf..539e9d25 100644 --- a/src/SimpleReplay/extract.py +++ b/src/SimpleReplay/extract.py @@ -5,6 +5,8 @@ import logging import os import re +import sys + import redshift_connector import threading import time @@ -850,9 +852,15 @@ def get_s3_audit_logs( else: curr_index -= 1 - logger.debug( - f'First audit log in start_time range: {audit_objects[curr_index]["Key"].split("/")[-1]}' - ) + try: + logger.debug( + f'First audit log in start_time range: {audit_objects[curr_index]["Key"].split("/")[-1]}' + ) + except IndexError: + logger.fatal(f"There was no user activity log available yet.") + logger.fatal("Make sure audit logging and user activity logging are enabled and await shipment of the logs.") + sys.exit(1) + return (connections, logs, databases, last_connections)