From 5cd45afe57e40414a4d9a5ca7fc811a5c0a78544 Mon Sep 17 00:00:00 2001 From: Steven Massaro Date: Wed, 24 Jan 2024 07:37:26 -0600 Subject: [PATCH] check that healthchecks url is a string and make log message more generic --- lib/config.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/config.py b/lib/config.py index 0bab5628..e7e5f63b 100644 --- a/lib/config.py +++ b/lib/config.py @@ -56,6 +56,14 @@ def _parse_config(self, config: JSON) -> None: if not isinstance(self.check_fares, bool): raise ConfigError("'check_fares' must be a boolean") + if "healthchecks_url" in config: + self.healthchecks_url = config["healthchecks_url"] + + if not isinstance(self.healthchecks_url, str): + raise ConfigError("'healthchecks_url' must be a string") + + logger.debug("A Healthchecks URL has been provided") + if "notification_level" in config: notification_level = config["notification_level"] try: @@ -97,10 +105,6 @@ def _parse_config(self, config: JSON) -> None: # Convert hours to seconds self.retrieval_interval *= 3600 - if "healthchecks_url" in config: - self.healthchecks_url = config["healthchecks_url"] - logger.debug("Setting healthchecks URL to %s", self.healthchecks_url) - class GlobalConfig(Config): def __init__(self) -> None: