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(framework,api): add source when triggered from workflow #6504

Open
wants to merge 11 commits into
base: next
Choose a base branch
from

Conversation

ainouzgali
Copy link
Contributor

@ainouzgali ainouzgali commented Sep 15, 2024

What changed? Why was the change needed?

Fix: Triggering a workflow from the bridge app, without syncing the workflow resulted in a successful trigger. Instead, should throw an error.

The tricky part with this "bug" is that there are multiple other cases where we do want to allow trigger of an un-synced workflow (like studio test trigger, trigger of the onboarding playground). They all reach the same api code snippet, as they contain a bridgeUrl, what I was looking for was to find a way to "force" this case, of workflowIdentifier.trigger to signal that this one does require a sync unlike the others.

The best way I found, that I felt was the most clean and still works with all other different usecases we have at this moment, is to add the __source to the payload to indicate that. When the functionality grows, we would need to do it in a more clever way - not only here but for all "stateless" workflows. Maybe have an explicit flag as part of the trigger structure, but that would be a major change for the context of this issue

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

linear bot commented Sep 15, 2024

@ainouzgali ainouzgali marked this pull request as draft September 15, 2024 14:18
@ainouzgali ainouzgali changed the title feat: add source when triggered from workflow feat(framework,api): add source when triggered from workflow Sep 15, 2024
Copy link
Contributor

@djabarovgeorge djabarovgeorge left a comment

Choose a reason for hiding this comment

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

Great job spotting all the uses in the trigger flow. I was surprised to see that we're passing the bridge URL by default. This means that for every request, we’re relying less on the state stored in the database.

As a result, instead of querying the database for workflow entities and control variables, the API performs a bridge discovery request and sends the data to the trigger engine.

In my opinion, this isn’t the expected behavior. We might need to add a new flag to explicitly decide whether the flow should be stateful or stateless.

@djabarovgeorge
Copy link
Contributor

Great job spotting all the uses in the trigger flow. I was surprised to see that we're passing the bridge URL by default. This means that for every request, we’re relying less on the state stored in the database.

As a result, instead of querying the database for workflow entities and control variables, the API performs a bridge discovery request and sends the data to the trigger engine.

In my opinion, this isn’t the expected behavior. We might need to add a new flag to explicitly decide whether the flow should be stateful or stateless.

@rifont What do you think about this? Let me know if you need more context. I’m a bit concerned about giving users the option to choose an unsynced (stateless) flow.

Copy link

pkg-pr-new bot commented Sep 19, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/novuhq/novu/@novu/js@6504

commit: 03a3faa

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.

2 participants