Skip to content

Commit

Permalink
alerts: handle nil case when fetching query ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
SaaldjorMike committed Nov 18, 2024
1 parent 446d21e commit de5e775
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/api/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ func (a *Alerts) Add(searchDomainName string, newAlert *Alert) (*Alert, error) {

respUpdate := resp.GetCreateAlert()
respQueryOwnership := respUpdate.GetQueryOwnership()
runAsUserID := ""
respRunAsUserID := ""
respOwnershipType := ""
if respQueryOwnership != nil {
runAsUserID = respQueryOwnership.GetId()
respRunAsUserID = respQueryOwnership.GetId()
respOwnershipTypename := respQueryOwnership.GetTypename()
if respOwnershipTypename != nil {
respOwnershipType = *respOwnershipTypename
}
}
return &Alert{
ID: respUpdate.GetId(),
Expand All @@ -118,8 +123,8 @@ func (a *Alerts) Add(searchDomainName string, newAlert *Alert) (*Alert, error) {
Actions: respUpdate.GetActions(),
Labels: respUpdate.GetLabels(),
LastError: respUpdate.LastError,
RunAsUserID: runAsUserID,
QueryOwnershipType: *respQueryOwnership.GetTypename(),
RunAsUserID: respRunAsUserID,
QueryOwnershipType: respOwnershipType,
}, nil
}

Expand Down

0 comments on commit de5e775

Please sign in to comment.