-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add flow to run output #10220
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
Add flow to run output #10220
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR enhances workflow run history by storing workflow version triggers and steps directly in the run output, ensuring runs remain accurate even if draft versions are modified later.
- Added
flow
field inWorkflowRunOutput
to store version trigger and steps in/packages/twenty-server/src/modules/workflow/common/standard-objects/workflow-run.workspace-entity.ts
- Renamed
steps
tostepsOutput
in output structures for clarity and separation of concerns - Added
WORKFLOW_RUN_INVALID
exception code in/packages/twenty-server/src/modules/workflow/workflow-runner/exceptions/workflow-run.exception.ts
- Modified
startWorkflowRun
to include initial flow data in/packages/twenty-server/src/modules/workflow/workflow-runner/workflow-run/workflow-run.workspace-service.ts
- Removed Logger dependency from workflow execution services for simplified error handling
5 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
.../twenty-server/src/modules/workflow/common/standard-objects/workflow-run.workspace-entity.ts
Show resolved
Hide resolved
...y-server/src/modules/workflow/workflow-runner/workflow-run/workflow-run.workspace-service.ts
Show resolved
Hide resolved
export type WorkflowExecutorState = { | ||
flow: WorkflowRunOutput['flow']; | ||
stepsOutput: WorkflowRunOutput['stepsOutput']; | ||
status: WorkflowRunStatus; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: flow field is defined but never populated in the executor state
await this.workflowRunWorkspaceService.saveWorkflowRunState({ | ||
workflowRunId, | ||
output: { | ||
steps: updatedOutputSteps, | ||
stepsOutput: updatedStepsOutput, | ||
}, | ||
context: updatedContext, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: flow field is missing in saveWorkflowRunState calls, which could lead to incomplete state persistence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed, this change will make the front-end's life way easier to compute a diagram for workflow runs. We can merge.
Please note that this change will break the frontend. We must fix it early next week.
trigger: WorkflowTrigger; | ||
steps: WorkflowAction[]; | ||
}; | ||
stepsOutput: Record<string, StepRunOutput>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
flow: { | ||
trigger: workflowVersion.trigger, | ||
steps: workflowVersion.steps, | ||
}, | ||
stepsOutput: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
output: { | ||
flow: workflowRunToUpdate.output?.flow ?? { | ||
trigger: undefined, | ||
steps: [], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the workflowRunToUpdate.output?.flow
should never be undefined. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can actually. When the run is not started yet. We should only store the flow once started because this is the version we'll execute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👌
We need the version trigger and steps to be stored in the output. We should not rely on the version itself because some run are made on draft versions. Which means versions could be edited afterwards.