fix(notifications): a line break in a rule name no longer stops the alert email (#5064)
The rule name goes into the Subject header, and EmailMessage refuses a header holding a line break, so the whole email failed. The web form can't enter one but MCP takes any string. The subject now folds whitespace. Found by the new From-fallback test in CI run 8349. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,7 +57,8 @@ def email_body(alert: dict) -> str:
|
||||
async def _send_email(cfg: dict, alert: dict) -> dict:
|
||||
try:
|
||||
msg = EmailMessage()
|
||||
msg["Subject"] = f"[Steward] {alert['state']} — {alert['rule_name']}"
|
||||
# A header may not hold a line break; a rule name can (MCP takes any string).
|
||||
msg["Subject"] = " ".join(f"[Steward] {alert['state']} — {alert['rule_name']}".split())
|
||||
msg["From"] = cfg.get("from") or cfg.get("username") or "steward@localhost"
|
||||
msg["To"] = ", ".join(cfg["recipients"])
|
||||
msg.set_content(email_body(alert))
|
||||
|
||||
Reference in New Issue
Block a user