Skip to content

Commit dfa1d7b

Browse files
committed
raise an error if neither API keys are set
1 parent 2c741be commit dfa1d7b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

backend/tenantfirstaid/shared.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ class Config:
3131
db_username: Optional[str] = field(default=None)
3232
db_password: Optional[str] = field(default=None)
3333

34+
def __post_init__(self):
35+
"""Post-initialization to ensure one of the API KEYs is not None."""
36+
if self.github_api_key is None and self.openai_api_key is None:
37+
raise ValueError(
38+
"Either GITHUB_API_KEY or OPENAI_API_KEY must be set in the environment variables."
39+
)
40+
3441

3542
# For development purposes, we expect the .env file to be in the backend directory
3643
__shared_py_path = Path(__file__).resolve()

0 commit comments

Comments
 (0)