Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions signing/watch/notify_corp_admin.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package watch

import (
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -151,6 +152,9 @@ func (impl *notifyAdminWatchImpl) isCorpSigningLatest(latestCLAs []domain.CLA, s
}

func (impl *notifyAdminWatchImpl) handleSendEmail(link *repository.LinkCLA, corp *repository.CorpSigningSummary) error {
if corp.Admin.Name == nil {
return fmt.Errorf("failed to send email msg: admin name is null: %s", link.Id)
}
Comment on lines +155 to +157

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While adding the nil check for corp.Admin.Name is a good fix, this function has other potential nil pointer dereferences that should also be handled. Specifically, corp.Admin.EmailAddr (used on line 171) and link.Email.Addr (used on line 170) could also be nil, leading to panics. It's best to add guard clauses for all of them at the beginning of the function for robustness. I've also updated the error messages to include the corporation ID for better context where applicable.

Suggested change
if corp.Admin.Name == nil {
return fmt.Errorf("failed to send email msg: admin name is null: %s", link.Id)
}
if corp.Admin.Name == nil {
return fmt.Errorf("failed to send email msg: admin name is null for corp %s", corp.Id)
}
if corp.Admin.EmailAddr == nil {
return fmt.Errorf("failed to send email msg: admin email is null for corp %s", corp.Id)
}
if link.Email.Addr == nil {
return fmt.Errorf("failed to send email msg: link email address is null for link %s", link.Id)
}

builder := emailtmpl.CLAUpdated{
Org: link.Org.Alias,
AdminName: corp.Admin.Name.Name(),
Expand Down