semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

Problem: Improve email alert error logging - add recipient context

Open steevivo opened this issue 3 months ago • 2 comments

Issue

Hi, When email alerts fail to send the error logs lack context about which recipient failed, making debugging difficult.

  • Failure logs don't show recipient (inconsistent)
  • Hard to debug when multiple users/tasks involved
  • No clear indication it's an email sending failure vs other errors

Suggested implementation : Wrap mailer errors with recipient context, similar to success message : Sent successfully email alert to [email protected] Discovered while debugging SMTP authentication issues. The improved logging would have saved significant debugging time.

Impact

Configuration

Installation method

Docker

Database

Postgres

Browser

Chrome

Semaphore Version

2.16

Ansible Version


Logs & errors

No response

Manual installation - system information

No response

Configuration

No response

Additional information

No response

steevivo avatar Nov 06 '25 16:11 steevivo

Today:

services/tasks/alert.go
if err := mailer.Send(...); err != nil {
       log.Error(err.Error())
   }

Suggested:

   if err := mailer.Send(...); err != nil {
       log.Error("Failed to send email alert to " + recipient + ": " + err.Error())
  }

steevivo avatar Nov 06 '25 16:11 steevivo

Hi @steevivo yes, we use logging with context for new code, something like this.

log.WithFields({"context": "email", ...}).WithError(err).Error("Failed to send email alert");

But old code can contains contextless error messages.

fiftin avatar Nov 06 '25 17:11 fiftin