Skip to content

Commit de5e775

Browse files
committed
alerts: handle nil case when fetching query ownership
1 parent 446d21e commit de5e775

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

internal/api/alerts.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,14 @@ func (a *Alerts) Add(searchDomainName string, newAlert *Alert) (*Alert, error) {
100100

101101
respUpdate := resp.GetCreateAlert()
102102
respQueryOwnership := respUpdate.GetQueryOwnership()
103-
runAsUserID := ""
103+
respRunAsUserID := ""
104+
respOwnershipType := ""
104105
if respQueryOwnership != nil {
105-
runAsUserID = respQueryOwnership.GetId()
106+
respRunAsUserID = respQueryOwnership.GetId()
107+
respOwnershipTypename := respQueryOwnership.GetTypename()
108+
if respOwnershipTypename != nil {
109+
respOwnershipType = *respOwnershipTypename
110+
}
106111
}
107112
return &Alert{
108113
ID: respUpdate.GetId(),
@@ -118,8 +123,8 @@ func (a *Alerts) Add(searchDomainName string, newAlert *Alert) (*Alert, error) {
118123
Actions: respUpdate.GetActions(),
119124
Labels: respUpdate.GetLabels(),
120125
LastError: respUpdate.LastError,
121-
RunAsUserID: runAsUserID,
122-
QueryOwnershipType: *respQueryOwnership.GetTypename(),
126+
RunAsUserID: respRunAsUserID,
127+
QueryOwnershipType: respOwnershipType,
123128
}, nil
124129
}
125130

0 commit comments

Comments
 (0)