semaphore
semaphore copied to clipboard
Problem: Improve email alert error logging - add recipient context
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
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())
}
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.