From 58d8f0b05c53a97e973ee5f5acf7742de112b79b Mon Sep 17 00:00:00 2001 From: Graham Hukill Date: Thu, 12 Dec 2024 13:49:53 -0500 Subject: [PATCH] Remove SENTRY_DSN from required env vars Why these changes are being introduced: For local development, or external users of this application, it does not make sense to require a SENTRY_DSN environment variable. While setting this to 'none' would satisfy the config setup, and not use Sentry, it feels unnecessary. How this addresses that need: * Moves SENTRY_DSN to optional env vars in Config class Side effects of this change: * SENTRY_DSN is no longer required as an env var, but providing it will still get picked up used Relevant ticket(s): * None --- README.md | 6 +++--- harvester/config.py | 4 ++-- tests/test_config.py | 8 -------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c4b6e94..10fd93f 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,10 @@ WORKSPACE=dev RECORD_SKIP_LIST= # Sets the interval for logging status updates as records are written to the output file. Defaults to 1000, which will log a status update for every thousandth record. -STATUS_UPDATE_INTERVAL = 1000 +STATUS_UPDATE_INTERVAL=1000 -# If set to a valid Sentry DSN, enables Sentry exception monitoring This is not needed for local development. -SENTRY_DSN = +# If set to a valid Sentry DSN, enables Sentry exception monitoring. This can also be set to 'none'. +SENTRY_DSN= ``` ## CLI commands diff --git a/harvester/config.py b/harvester/config.py index 1af6a1f..6b21bb2 100644 --- a/harvester/config.py +++ b/harvester/config.py @@ -14,8 +14,8 @@ class Config: - REQUIRED_ENV_VARS = ("WORKSPACE", "SENTRY_DSN") - OPTIONAL_ENV_VARS = ("RECORD_SKIP_LIST", "STATUS_UPDATE_INTERVAL") + REQUIRED_ENV_VARS = ("WORKSPACE",) + OPTIONAL_ENV_VARS = ("RECORD_SKIP_LIST", "SENTRY_DSN", "STATUS_UPDATE_INTERVAL") def __init__(self, logger: logging.Logger | None = None): """Set root logger as default when creating class instance.""" diff --git a/tests/test_config.py b/tests/test_config.py index e6e7060..52e577f 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -51,14 +51,6 @@ def test_config_check_required_env_vars_success(config): config.check_required_env_vars() -def test_config_check_required_env_vars_error(config, monkeypatch): - monkeypatch.delenv("SENTRY_DSN") - with pytest.raises( - OSError, match="Missing required environment variables: SENTRY_DSN" - ): - config.check_required_env_vars() - - def test_config_env_var_access_success(config): assert config.STATUS_UPDATE_INTERVAL == "1000"