From 5d2deed72a377452d3badbd130831811d7d64dde Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Mon, 28 Mar 2022 13:14:54 -0400 Subject: [PATCH] api/graph/events: Fix panic for external participants in SendEmail Previously, SQL queries in SendEmail would return NULL for participant types other than 'user' or 'email'. This would panic for participant types like 'external' since NULL cannot be scanned to a string, which caused the submitTicket mutation to fail when called with an externalId. Fix by returning and checking for an empty string instead. --- api/graph/events.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/graph/events.go b/api/graph/events.go index ea63f83..368b79e 100644 --- a/api/graph/events.go +++ b/api/graph/events.go @@ -295,12 +295,12 @@ func (builder *EventBuilder) SendEmails(subject string, CASE part.participant_type WHEN 'user' THEN '~' || "user".username WHEN 'email' THEN part.email_name - ELSE null END + ELSE '' END `, ` CASE part.participant_type WHEN 'user' THEN "user".email WHEN 'email' THEN part.email - ELSE null END + ELSE '' END `). Distinct(). From(`event_participant evpart`). @@ -320,6 +320,9 @@ func (builder *EventBuilder) SendEmails(subject string, if err := rows.Scan(&name, &address); err != nil { panic(err) } + if len(name) == 0 || len(address) == 0 { + continue + } if address == user.Email { if notifySelf { copiedSelf = true