Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding guard condition for empty notification list in notify fun… #182

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

utsav14nov
Copy link

…ction

@utsav14nov utsav14nov self-assigned this Oct 8, 2024
Copy link
Collaborator

@Gadigeppa-J Gadigeppa-J left a comment

Choose a reason for hiding this comment

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

lgtm

@Gadigeppa-J Gadigeppa-J merged commit 8ac4398 into main Oct 8, 2024
4 checks passed
@rahmatrhd
Copy link
Member

we might have missed a logic to filter the list of notification payload (notification) based on expression https://github.com/goto/guardian/pull/182/files#diff-e9d4420e58365047a594e01257c7cb0163b2856c897c1b71d125d188d8b18873R34-R43

what supposed to be done is:

  1. NotifyManager holds information of multiple client e.g. slack and lark
  2. NotifyManager.Notify accepts []notification and it is responsible to send notif to multiple clients according to the configured expression in each client
  3. in this case, we need to pass only []notification that fulfilled the expression evaluation to the (client.Notify)

@utsav14nov
Copy link
Author

utsav14nov commented Oct 9, 2024

Got it. That’s what is my concern.

But Guard condition in this MR changes still needed as it was breaking at "email": notification[0].User when []notification length is 0

Here, Expression expects email from : "email": notification[0].User i.e. from first notification in []notification list.
But this should check this criteria for email in each notification in []notification list.
So IMO, https://github.com/goto/guardian/pull/182/files#diff-e9d4420e58365047a594e01257c7cb0163b2856c897c1b71d125d188d8b18873L32-L48
should also be wrapped inside loop iterating over []notification and client.Notify(ctx, notification) call should be called with single notification each time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants