fix: move hardcoded Discord webhook URL to env var #83

Merged
cal merged 4 commits from fix/remove-hardcoded-webhook into main 2026-04-08 02:28:21 +00:00
Showing only changes of commit 3be4f71e22 - Show all commits

View File

@ -503,6 +503,9 @@ def update_season_pitching_stats(player_ids, season, db_connection):
raise
DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL")
Outdated
Review

All other env-var module-level constants (REDIS_HOST, REDIS_PORT, REDIS_DB, CACHE_ENABLED) are grouped together near the top of the file around lines 26–29. Declaring this one mid-file is inconsistent with that pattern. Consider moving it there.

All other env-var module-level constants (`REDIS_HOST`, `REDIS_PORT`, `REDIS_DB`, `CACHE_ENABLED`) are grouped together near the top of the file around lines 26–29. Declaring this one mid-file is inconsistent with that pattern. Consider moving it there.
def send_webhook_message(message: str) -> bool:
"""
Send a message to Discord via webhook.
@ -513,7 +516,12 @@ def send_webhook_message(message: str) -> bool:
Returns:
bool: True if successful, False otherwise
"""
webhook_url = "https://discord.com/api/webhooks/1408811717424840876/7RXG_D5IqovA3Jwa9YOobUjVcVMuLc6cQyezABcWuXaHo5Fvz1en10M7J43o3OJ3bzGW"
webhook_url = DISCORD_WEBHOOK_URL
Outdated
Review

DISCORD_WEBHOOK_URL is not included in the api service environment block in docker-compose.yml. Without - DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL} in that file, this os.environ.get will always return None in every deployed environment (dev and prod) and the webhook will silently do nothing.

`DISCORD_WEBHOOK_URL` is not included in the `api` service `environment` block in `docker-compose.yml`. Without `- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}` in that file, this `os.environ.get` will always return `None` in every deployed environment (dev and prod) and the webhook will silently do nothing.
if not webhook_url:
logger.warning(
"DISCORD_WEBHOOK_URL env var is not set — skipping webhook message"
)
return False
try:
payload = {"content": message}