Ensure success email subject is never blank; add final guard in send_email
Mirror and run GitLab CI / build (push) Has been cancelled
Ruff / ruff (push) Has been cancelled

This commit is contained in:
admin
2026-06-14 21:56:04 +00:00
parent 6c11a8f19a
commit 4651c5f8b2
2 changed files with 18 additions and 3 deletions
+11 -2
View File
@@ -166,13 +166,22 @@ def send_success_email(
Falls back to a safe default if the env var is missing or blank.
"""
# Read subject from environment; never allow blank
subject = (os.getenv("EMAIL_SUBJECT_SUCCESS") or "").strip()
raw_subject = os.getenv("EMAIL_SUBJECT_SUCCESS")
subject = (raw_subject or "").strip()
if not subject:
subject = "ScrAIbe: Your transcript is ready"
logger.info("EMAIL_SUBJECT_SUCCESS not set or blank; using default subject.")
logger.info(
"EMAIL_SUBJECT_SUCCESS not set or blank; using default subject: %s", subject
)
else:
logger.info("Using EMAIL_SUBJECT_SUCCESS: %s", subject)
# Final guard: ensure subject is never empty
if not subject:
subject = "ScrAIbe: Your transcript is ready"
logger.warning("Subject was empty after reading; forced default subject.")
body = (
"Hello,\n\n"
"Your transcription is ready.\n\n"