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

feat(api): fail inactive notification trigger #7347

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

djabarovgeorge
Copy link
Contributor

What changed? Why was the change needed?

We added issue management under the workflow entity, but we never enforced its usage. This PR ensures that notifications won't be triggered for statuses that are not active.

At the same time, to improve the user experience, we're allowing users to trigger the "Trigger" action directly from the Dashboard. This helps them quickly identify issues while debugging the workflow.

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

netlify bot commented Dec 22, 2024

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit a43232e
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/676892ff071ce7000850d4a5
😎 Deploy Preview https://deploy-preview-7347.dashboard.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 22, 2024

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit a43232e
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/676892ffb2610d0008981e5c
😎 Deploy Preview https://deploy-preview-7347.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -405,6 +421,10 @@ export class ParseEventRequest {
private isBlockedEmail(email: string): boolean {
return BLOCKED_DOMAINS.some((domain) => email.includes(domain));
}

private isGracefulTriggerAllowed(source?: string): boolean {
return source === TriggerSourceEnum.DASHBOARD;
Copy link
Contributor

Choose a reason for hiding this comment

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

@djabarovgeorge, why do we need to check the source for this? I suggest just using the status for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please see the description of the PR

At the same time, to improve the user experience, we're allowing users to trigger the "Trigger" action directly from the Dashboard. This helps them quickly identify issues while debugging the workflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know what you think, i am fine removing it because now the trigger is less predicted, but in the same time it will cost workflow debugging flow.

Copy link
Contributor

Choose a reason for hiding this comment

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

I tend to agree with sok, I think trigger should be predictable and throw an error when in a bad step, not the type of things you want to learn about in prod

Copy link
Contributor

Choose a reason for hiding this comment

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

Following on this, @djabarovgeorge is right. Without a more sophisticated way to test an inactive workflow from the Dashboard we will need this hack in the logic to allow Novu users to test workflows from the Dashboard.

But this means we must ensure the API request comes from the Dashboard. That is, we should verify the source and the fact that a JWT (not an API key) was used for authentication.

Copy link
Contributor Author

@djabarovgeorge djabarovgeorge Dec 24, 2024

Choose a reason for hiding this comment

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

How do we feel about adding additional indicators for this case?

  1. If the status is ERROR, we could either:
    • Change the button color, or
    • Add a warning icon to highlight the workflow status.
  2. If the status is ERROR, the payload could include an extra parameter to show the trigger override, for example:
payload:
{
  "__debugModeBypassStatus": true,
  ...otherParams
}

the API will check the __source and this new param __debugModeBypassStatus

Comment on lines +158 to +160
return {
acknowledged: true,
status: TriggerEventStatusEnum.NOT_ACTIVE,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we report a better status here? And potentially also pass the actual errors in the response? I would also actually throw a 4XX error here instead of returning 200

Copy link
Contributor

Choose a reason for hiding this comment

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

The status code depends on how we handled the trigger endpoint. Returning 4XX can be a breaking change for some customers who don't handle errors when doing novu.trigger. So, for now, we should return whatever the API was returning.

Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't thought of the active one, but for the Error checks, I would still return an error

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

Successfully merging this pull request may close these issues.

3 participants