Improve error handling in settings retrieval

Fix bug where default values were not being used in GitHub Action runners when environmental variables are not set. Now, if an environmental variable cannot be found and no default is given, the default value will be used if one exists. This will prevent errors during setup on different environments and ensure system stability.
This commit is contained in:
Ori Kotek
2023-11-29 11:52:02 +02:00
parent b67d06ae59
commit 0e54a13272

View File

@ -25,7 +25,7 @@ def get_setting_or_env(key: str, default: Union[str, bool] = None) -> Union[str,
try:
value = get_settings().get(key, default)
except AttributeError: # TBD still need to debug why this happens on GitHub Actions
value = os.getenv(key, None) or os.getenv(key.upper(), None) or os.getenv(key.lower(), None)
value = os.getenv(key, None) or os.getenv(key.upper(), None) or os.getenv(key.lower(), None) or default
return value