Ensure success email subject is never blank; add final guard in send_email
This commit is contained in:
@@ -221,7 +221,13 @@ def send_email(
|
|||||||
msg["To"] = ", ".join(to_list)
|
msg["To"] = ", ".join(to_list)
|
||||||
if cc_list:
|
if cc_list:
|
||||||
msg["Cc"] = ", ".join(cc_list)
|
msg["Cc"] = ", ".join(cc_list)
|
||||||
msg["Subject"] = subject
|
|
||||||
|
# Ensure subject is never blank
|
||||||
|
if not subject or not subject.strip():
|
||||||
|
logger.warning("Subject was blank; using default subject.")
|
||||||
|
subject = "ScrAIbe: Your transcript is ready"
|
||||||
|
|
||||||
|
msg["Subject"] = subject.strip()
|
||||||
|
|
||||||
# Attach plain text
|
# Attach plain text
|
||||||
msg.attach(MIMEText(body, "plain"))
|
msg.attach(MIMEText(body, "plain"))
|
||||||
|
|||||||
+11
-2
@@ -166,13 +166,22 @@ def send_success_email(
|
|||||||
Falls back to a safe default if the env var is missing or blank.
|
Falls back to a safe default if the env var is missing or blank.
|
||||||
"""
|
"""
|
||||||
# Read subject from environment; never allow 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:
|
if not subject:
|
||||||
subject = "ScrAIbe: Your transcript is ready"
|
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:
|
else:
|
||||||
logger.info("Using EMAIL_SUBJECT_SUCCESS: %s", subject)
|
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 = (
|
body = (
|
||||||
"Hello,\n\n"
|
"Hello,\n\n"
|
||||||
"Your transcription is ready.\n\n"
|
"Your transcription is ready.\n\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user