Bug Report
Root Cause: notify/email/email.go, function New() (line ~54-58), accesses the c.Headers map without first checking if it is nil. When an EmailConfig is created programmatically by the query-service pushing channel config via /api/v1/routes without an explicit headers: YAML field, Headers is a nil map[string]string. Map reads succeed (returning zero value + false), but the subsequent map writes panic.
Stack trace:
http: panic serving: assignment to entry in nil map
github.com/prometheus/alertmanager/notify/email.New(...)
/app/notify/email/email.go:55
Buggy code in notify/email/email.go lines 54-65:
func New(c *config.EmailConfig, t *template.Template, l log.Logger) *Email {
if _, ok := c.Headers["Subject"]; !ok { // panics if c.Headers is nil
c.Headers["Subject"] = config.DefaultEmailSubject
}
if _, ok := c.Headers["To"]; !ok {
c.Headers["To"] = c.To
}
if _, ok := c.Headers["From"]; !ok {
c.Headers["From"] = c.From
}
...
}
Fix — one-line nil guard before first map access:
func New(c *config.EmailConfig, t *template.Template, l log.Logger) *Email {
if c.Headers == nil {
c.Headers = make(map[string]string)
}
if _, ok := c.Headers["Subject"]; !ok {
c.Headers["Subject"] = config.DefaultEmailSubject
}
...
}
Reproduction:
- Deploy SigNoz with alertmanager
signoz/alertmanager:latest (v0.23.9)
- Create an email notification channel via SigNoz UI (Settings → Alert Channels)
- Click Test — query-service returns 500, alertmanager pod logs show the panic above
Workaround until fixed: Pre-configure the alertmanager alertmanager.yml with a default receiver containing an explicit headers: block so the Headers map is initialized from YAML deserialization rather than being nil.
Environment: signoz/alertmanager:latest (v0.23.9), linux/arm64 and amd64, triggered via /api/v1/testReceiver endpoint.
Bug Report
Root Cause:
notify/email/email.go, functionNew()(line ~54-58), accesses thec.Headersmap without first checking if it is nil. When anEmailConfigis created programmatically by the query-service pushing channel config via/api/v1/routeswithout an explicitheaders:YAML field,Headersis a nilmap[string]string. Map reads succeed (returning zero value + false), but the subsequent map writes panic.Stack trace:
Buggy code in
notify/email/email.golines 54-65:Fix — one-line nil guard before first map access:
Reproduction:
signoz/alertmanager:latest(v0.23.9)Workaround until fixed: Pre-configure the alertmanager
alertmanager.ymlwith a default receiver containing an explicitheaders:block so theHeadersmap is initialized from YAML deserialization rather than being nil.Environment:
signoz/alertmanager:latest(v0.23.9), linux/arm64 and amd64, triggered via/api/v1/testReceiverendpoint.