Skip to content

Commit

Permalink
Better error handling for unset env variables, eg the HAPI key
Browse files Browse the repository at this point in the history
  • Loading branch information
dividor committed Jun 16, 2024
1 parent f333570 commit ff3560c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def replace_env_variables(value):
elif isinstance(value, str):
matches = re.findall(r"\{\{ (.+?) \}\}", value)
for match in matches:
if os.getenv(match) is None:
print(f"Environment variable {match} is not set.")
sys.exit(1)

value = value.replace("{{ " + match + " }}", os.getenv(match))
return value
else:
Expand Down

0 comments on commit ff3560c

Please sign in to comment.