diff --git a/openqabot/approver.py b/openqabot/approver.py index f428ff3..f9e03c5 100644 --- a/openqabot/approver.py +++ b/openqabot/approver.py @@ -165,7 +165,12 @@ def was_ok_before(self, failed_job_id: int, inc: int) -> bool: return False current_build = older_jobs["data"][0]["build"][:-2] - current_build_date = datetime.strptime(current_build, "%Y%m%d") + try: + current_build_date = datetime.strptime(current_build, "%Y%m%d") + except (ValueError, TypeError): + log.info("Could not parse build date %s", current_build) + return False + # Use at most X days old build. Don't go back in time too much to reduce risk of using invalid tests oldest_build_usable = current_build_date - timedelta( @@ -177,7 +182,11 @@ def was_ok_before(self, failed_job_id: int, inc: int) -> bool: for i in range(1, len(older_jobs["data"])): job = older_jobs["data"][i] job_build = job["build"][:-2] - job_build_date = datetime.strptime(job_build, "%Y%m%d") + try: + job_build_date = datetime.strptime(job_build, "%Y%m%d") + except (ValueError, TypeError): + log.info("Could not parse build date %s", current_build) + continue # Check the job is not too old if job_build_date < oldest_build_usable: