Skip to content

The open alternative to Salesforce, designed for AI.

feat(workflow): honor retryOnFailure in the executor (#25248)

Thomas Trompette171bfbdc3ca6
diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/build-logic-function-step.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/build-logic-function-step.test.ts
index 934ea297141..4835f7ea8e6 100644
--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/build-logic-function-step.test.ts
+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/build-logic-function-step.test.ts
@@ -23,7 +23,7 @@ describe('buildLogicFunctionStep', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/build-logic-function-step.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/build-logic-function-step.ts
index a47f0ecbe2d..b0686deab2b 100644
--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/build-logic-function-step.ts
+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/build-logic-function-step.ts
@@ -22,7 +22,7 @@ export const buildLogicFunctionStep = ({
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-apps/public/people-data-labs/src/types/workflow-logic-function-step.ts b/packages/twenty-apps/public/people-data-labs/src/types/workflow-logic-function-step.ts
index 993c099f32e..82cf555848a 100644
--- a/packages/twenty-apps/public/people-data-labs/src/types/workflow-logic-function-step.ts
+++ b/packages/twenty-apps/public/people-data-labs/src/types/workflow-logic-function-step.ts
@@ -10,7 +10,7 @@ export type WorkflowLogicFunctionStep = {
};
outputSchema: Record<string, never>;
errorHandlingOptions: {
- retryOnFailure: { value: boolean };
+ retryOnFailure: { value: number };
continueOnFailure: { value: boolean };
};
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/workflow/step/create/components/__tests__/SidePanelWorkflowCreateStepContent.test.tsx b/packages/twenty-front/src/modules/side-panel/pages/workflow/step/create/components/__tests__/SidePanelWorkflowCreateStepContent.test.tsx
index 92a30c60d6f..a867f7c74c6 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/workflow/step/create/components/__tests__/SidePanelWorkflowCreateStepContent.test.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/workflow/step/create/components/__tests__/SidePanelWorkflowCreateStepContent.test.tsx
@@ -39,7 +39,7 @@ const mockParentStep: WorkflowIfElseAction = {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/utils/__tests__/findStepPosition.test.ts b/packages/twenty-front/src/modules/workflow/utils/__tests__/findStepPosition.test.ts
index 54d2d3b3549..c834389f4ce 100644
--- a/packages/twenty-front/src/modules/workflow/utils/__tests__/findStepPosition.test.ts
+++ b/packages/twenty-front/src/modules/workflow/utils/__tests__/findStepPosition.test.ts
@@ -12,7 +12,7 @@ describe('findStepPosition', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
input: {
objectName: 'Company',
@@ -29,7 +29,7 @@ describe('findStepPosition', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
input: {
objectName: 'Company',
@@ -48,7 +48,7 @@ describe('findStepPosition', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
input: {
objectName: 'Company',
diff --git a/packages/twenty-front/src/modules/workflow/utils/__tests__/getStepDefinitionOrThrow.test.ts b/packages/twenty-front/src/modules/workflow/utils/__tests__/getStepDefinitionOrThrow.test.ts
index 17b972edbc7..de25ecffb56 100644
--- a/packages/twenty-front/src/modules/workflow/utils/__tests__/getStepDefinitionOrThrow.test.ts
+++ b/packages/twenty-front/src/modules/workflow/utils/__tests__/getStepDefinitionOrThrow.test.ts
@@ -23,7 +23,7 @@ describe('getStepDefinitionOrThrow', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
input: {
objectName: 'Company',
@@ -40,7 +40,7 @@ describe('getStepDefinitionOrThrow', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
input: {
objectName: 'Company',
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/hooks/__tests__/useReconnectWorkflowEdge.test.tsx b/packages/twenty-front/src/modules/workflow/workflow-diagram/hooks/__tests__/useReconnectWorkflowEdge.test.tsx
index ed223d2e8d8..9ee43cec74e 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/hooks/__tests__/useReconnectWorkflowEdge.test.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/hooks/__tests__/useReconnectWorkflowEdge.test.tsx
@@ -29,7 +29,7 @@ const createAction = (
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/generateWorkflowDiagram.test.ts b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/generateWorkflowDiagram.test.ts
index e9c53647e47..a4609abb01b 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/generateWorkflowDiagram.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/generateWorkflowDiagram.test.ts
@@ -51,7 +51,7 @@ describe('generateWorkflowDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -69,7 +69,7 @@ describe('generateWorkflowDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -128,7 +128,7 @@ describe('generateWorkflowDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -146,7 +146,7 @@ describe('generateWorkflowDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -193,7 +193,7 @@ describe('generateWorkflowDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -211,7 +211,7 @@ describe('generateWorkflowDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -258,7 +258,7 @@ describe('generateWorkflowDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -276,7 +276,7 @@ describe('generateWorkflowDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -294,7 +294,7 @@ describe('generateWorkflowDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -350,7 +350,7 @@ describe('generateWorkflowDiagram', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -365,7 +365,7 @@ describe('generateWorkflowDiagram', () => {
input: { method: 'GET', url: '', headers: {} },
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/generateWorkflowRunDiagram.test.ts b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/generateWorkflowRunDiagram.test.ts
index f70e68d1244..ef363ced458 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/generateWorkflowRunDiagram.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/generateWorkflowRunDiagram.test.ts
@@ -43,7 +43,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -61,7 +61,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -79,7 +79,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -277,7 +277,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -295,7 +295,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -313,7 +313,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -513,7 +513,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -531,7 +531,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -549,7 +549,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -749,7 +749,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -767,7 +767,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -785,7 +785,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -803,7 +803,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: {
@@ -1039,7 +1039,7 @@ describe('generateWorkflowRunDiagram', () => {
valid: true,
settings: {
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: false },
},
input: [
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/isLastStepOfLoop.test.ts b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/isLastStepOfLoop.test.ts
index 1758e62b791..b8b6757c27e 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/isLastStepOfLoop.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/isLastStepOfLoop.test.ts
@@ -15,7 +15,7 @@ describe('isLastStepOfLoop', () => {
input: { initialLoopStepIds },
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/separateParallelWorkflowEdges.test.ts b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/separateParallelWorkflowEdges.test.ts
index 20ed3a178c3..13be5e88f62 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/separateParallelWorkflowEdges.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/separateParallelWorkflowEdges.test.ts
@@ -28,7 +28,7 @@ const branchStep: WorkflowIfElseAction = {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/wouldReconnectWorkflowEdgeCreateCycle.test.ts b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/wouldReconnectWorkflowEdgeCreateCycle.test.ts
index 079d93d6276..510b7211ab5 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/wouldReconnectWorkflowEdgeCreateCycle.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/utils/__tests__/wouldReconnectWorkflowEdgeCreateCycle.test.ts
@@ -10,7 +10,7 @@ const createAction = (id: string, nextStepIds: string[]): WorkflowAction => ({
input: { method: 'GET', url: '', headers: {} },
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -63,7 +63,7 @@ describe('wouldReconnectWorkflowEdgeCreateCycle', () => {
input: { items: [], initialLoopStepIds: ['loop-first'] },
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/hooks/__tests__/useUpdateStep.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/hooks/__tests__/useUpdateStep.test.ts
index f8beb061936..a42b30ac2d4 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/hooks/__tests__/useUpdateStep.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/hooks/__tests__/useUpdateStep.test.ts
@@ -39,7 +39,7 @@ describe('useUpdateStep', () => {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: true,
+ value: 3,
},
continueOnFailure: {
value: true,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getIsDescendantOfIterator.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getIsDescendantOfIterator.test.ts
index 721e9f1e02b..5dfdf067394 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getIsDescendantOfIterator.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getIsDescendantOfIterator.test.ts
@@ -14,7 +14,7 @@ describe('getIsDescendantOfIterator', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: true },
},
},
@@ -33,7 +33,7 @@ describe('getIsDescendantOfIterator', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: true },
},
},
@@ -52,7 +52,7 @@ describe('getIsDescendantOfIterator', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: true },
},
},
@@ -92,7 +92,7 @@ describe('getIsDescendantOfIterator', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: true },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getStepInfoHistoryItem.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getStepInfoHistoryItem.test.ts
index 12d437eed17..461181ddb9c 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getStepInfoHistoryItem.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getStepInfoHistoryItem.test.ts
@@ -13,7 +13,7 @@ describe('getStepInfoHistoryItem', () => {
input: { initialLoopStepIds: ['step2'] },
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -32,7 +32,7 @@ describe('getStepInfoHistoryItem', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -76,6 +76,35 @@ describe('getStepInfoHistoryItem', () => {
).toBe('final');
});
+ it('keeps iterations aligned when a descendant of iterator was retried', () => {
+ const stepInfo: WorkflowRunStepInfo = {
+ result: 'final',
+ status: StepStatus.SUCCESS,
+ history: [
+ { error: 'first attempt', status: StepStatus.FAILED, retryAttempt: 1 },
+ { result: 'first', status: StepStatus.SUCCESS },
+ { result: 'second', status: StepStatus.SUCCESS },
+ ],
+ };
+
+ expect(
+ getStepInfoHistoryItem({
+ stepInfo,
+ steps,
+ stepId: 'step2',
+ iterationIndex: 0,
+ })?.result,
+ ).toBe('first');
+ expect(
+ getStepInfoHistoryItem({
+ stepInfo,
+ steps,
+ stepId: 'step2',
+ iterationIndex: 2,
+ })?.result,
+ ).toBe('final');
+ });
+
it('returns the last history item for a non-descendant', () => {
const stepInfo: WorkflowRunStepInfo = {
result: 'final',
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowPreviousSteps.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowPreviousSteps.test.ts
index 88a70c37003..ac882d6543f 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowPreviousSteps.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowPreviousSteps.test.ts
@@ -17,7 +17,7 @@ describe('getWorkflowPreviousSteps', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: true },
},
},
@@ -35,7 +35,7 @@ describe('getWorkflowPreviousSteps', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: true },
},
},
@@ -53,7 +53,7 @@ describe('getWorkflowPreviousSteps', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: true },
},
},
@@ -71,7 +71,7 @@ describe('getWorkflowPreviousSteps', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: true },
+ retryOnFailure: { value: 3 },
continueOnFailure: { value: true },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepContext.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepContext.test.ts
index ca91acf9bc8..b6a5e601ee2 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepContext.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepContext.test.ts
@@ -22,7 +22,7 @@ const mockFlow = {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -40,7 +40,7 @@ const mockFlow = {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -142,7 +142,7 @@ describe('getWorkflowRunStepContext', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -160,7 +160,7 @@ describe('getWorkflowRunStepContext', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -178,7 +178,7 @@ describe('getWorkflowRunStepContext', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepExecutionStatus.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepExecutionStatus.test.ts
index 203b22de61a..d19cb893d03 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepExecutionStatus.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepExecutionStatus.test.ts
@@ -43,7 +43,7 @@ describe('getWorkflowRunStepExecutionStatus', () => {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -107,7 +107,7 @@ describe('getWorkflowRunStepExecutionStatus', () => {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -172,7 +172,7 @@ describe('getWorkflowRunStepExecutionStatus', () => {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -204,7 +204,7 @@ describe('getWorkflowRunStepExecutionStatus', () => {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowVariablesUsedInStep.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowVariablesUsedInStep.test.ts
index fcb9cd70ebb..3563b422ee5 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowVariablesUsedInStep.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowVariablesUsedInStep.test.ts
@@ -18,7 +18,7 @@ describe('getWorkflowVariablesUsedInStep', () => {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -68,7 +68,7 @@ Set {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -109,7 +109,7 @@ Set {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -148,7 +148,7 @@ Set {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/reconnectWorkflowStep.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/reconnectWorkflowStep.test.ts
index 725c15e45c0..045865ba1fa 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/reconnectWorkflowStep.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/reconnectWorkflowStep.test.ts
@@ -21,7 +21,7 @@ const ifElseStep: WorkflowIfElseAction = {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getWorkflowRunAllStepInfoHistory.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getWorkflowRunAllStepInfoHistory.ts
index 82d42627b42..0d076341e89 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getWorkflowRunAllStepInfoHistory.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/getWorkflowRunAllStepInfoHistory.ts
@@ -1,4 +1,5 @@
import { isArray } from '@sniptt/guards';
+import { isDefined } from 'twenty-shared/utils';
import { type WorkflowRunStepInfo } from 'twenty-shared/workflow';
export const getWorkflowRunAllStepInfoHistory = ({
@@ -6,8 +7,12 @@ export const getWorkflowRunAllStepInfoHistory = ({
}: {
stepInfo: WorkflowRunStepInfo;
}) => {
+ const iterationHistory = isArray(stepInfo?.history)
+ ? stepInfo.history.filter((entry) => !isDefined(entry.retryAttempt))
+ : [];
+
const allStepInfoHistory: WorkflowRunStepInfo[] = [
- ...(isArray(stepInfo?.history) ? stepInfo.history : []),
+ ...iterationHistory,
stepInfo,
];
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/__stories__/WorkflowEditActionCode.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/__stories__/WorkflowEditActionCode.stories.tsx
index defb3e9e245..b9a9adc5eae 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/__stories__/WorkflowEditActionCode.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/__stories__/WorkflowEditActionCode.stories.tsx
@@ -26,7 +26,7 @@ const DEFAULT_ACTION: WorkflowCodeAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -65,7 +65,7 @@ const CONFIGURED_ACTION: WorkflowCodeAction = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: true,
+ value: 3,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionCreateRecord.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionCreateRecord.stories.tsx
index 366721386bb..3aaa827c218 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionCreateRecord.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionCreateRecord.stories.tsx
@@ -30,7 +30,7 @@ const meta: Meta<typeof WorkflowEditActionCreateRecord> = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionDeleteRecord.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionDeleteRecord.stories.tsx
index fa8177ffb79..e28db705628 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionDeleteRecord.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionDeleteRecord.stories.tsx
@@ -26,7 +26,7 @@ const DEFAULT_ACTION = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionEmailBase.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionEmailBase.stories.tsx
index de9e56777db..22931ce8e5a 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionEmailBase.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionEmailBase.stories.tsx
@@ -59,7 +59,7 @@ const DEFAULT_SEND_EMAIL_ACTION: WorkflowSendEmailAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -89,7 +89,7 @@ const CONFIGURED_SEND_EMAIL_ACTION: WorkflowSendEmailAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: true,
+ value: 3,
},
continueOnFailure: {
value: false,
@@ -119,7 +119,7 @@ const DEFAULT_DRAFT_EMAIL_ACTION: WorkflowDraftEmailAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -149,7 +149,7 @@ const VARIABLE_SENDER_SEND_EMAIL_ACTION: WorkflowSendEmailAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -179,7 +179,7 @@ const VARIABLE_SENDER_DRAFT_EMAIL_ACTION: WorkflowDraftEmailAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionFindRecords.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionFindRecords.stories.tsx
index d334aec1249..15149da11af 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionFindRecords.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionFindRecords.stories.tsx
@@ -24,7 +24,7 @@ const DEFAULT_ACTION = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionUpdateRecord.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionUpdateRecord.stories.tsx
index c351e084619..1dc8eee5331 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionUpdateRecord.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionUpdateRecord.stories.tsx
@@ -27,7 +27,7 @@ const DEFAULT_ACTION = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/__stories__/WorkflowEditActionFilter.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/__stories__/WorkflowEditActionFilter.stories.tsx
index f677828b36a..aadaf188361 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/__stories__/WorkflowEditActionFilter.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/__stories__/WorkflowEditActionFilter.stories.tsx
@@ -24,7 +24,7 @@ const DEFAULT_ACTION: WorkflowFilterAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -60,7 +60,7 @@ const CONFIGURED_ACTION: WorkflowFilterAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormBuilder.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormBuilder.stories.tsx
index d0fb20a993b..0fcea1e73ec 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormBuilder.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormBuilder.stories.tsx
@@ -38,7 +38,7 @@ const DEFAULT_ACTION = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormFieldSettings.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormFieldSettings.stories.tsx
index 3a0182272f5..af4c934cf68 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormFieldSettings.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormFieldSettings.stories.tsx
@@ -38,7 +38,7 @@ const mockAction: WorkflowFormAction = {
],
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormFiller.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormFiller.stories.tsx
index 08ff7c59cd5..ada789bb853 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormFiller.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/form-action/components/__stories__/WorkflowEditActionFormFiller.stories.tsx
@@ -75,7 +75,7 @@ const mockAction: WorkflowFormAction = {
],
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/HttpRequestTestVariableInput.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/HttpRequestTestVariableInput.tsx
index c9d70fa6963..771ede16a67 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/HttpRequestTestVariableInput.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/HttpRequestTestVariableInput.tsx
@@ -44,7 +44,7 @@ export const HttpRequestTestVariableInput = ({
input: httpRequestFormData,
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/__stories__/WorkflowEditActionHttpRequest.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/__stories__/WorkflowEditActionHttpRequest.stories.tsx
index b822788aa97..d989a47bed7 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/__stories__/WorkflowEditActionHttpRequest.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/components/__stories__/WorkflowEditActionHttpRequest.stories.tsx
@@ -29,7 +29,7 @@ const DEFAULT_ACTION: WorkflowHttpRequestAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -59,7 +59,7 @@ const CONFIGURED_ACTION: WorkflowHttpRequestAction = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: true,
+ value: 3,
},
continueOnFailure: {
value: false,
@@ -170,7 +170,7 @@ export const WithArrayStringBody: Story = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -220,7 +220,7 @@ export const WithObjectStringBody: Story = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -276,7 +276,7 @@ export const WithArrayContainingNonStringVariablesBody: Story = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -323,7 +323,7 @@ export const WithObjectContainingNonStringVariablesBody: Story = {
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/__tests__/useHttpRequestForm.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/__tests__/useHttpRequestForm.test.ts
index 998834f7c34..0b83ed9ed0f 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/__tests__/useHttpRequestForm.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/http-request-action/hooks/__tests__/useHttpRequestForm.test.ts
@@ -17,7 +17,7 @@ describe('useHttpRequestForm', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-front/src/testing/mock-data/workflow-run.ts b/packages/twenty-front/src/testing/mock-data/workflow-run.ts
index 4083b736f9a..deced67c1b5 100644
--- a/packages/twenty-front/src/testing/mock-data/workflow-run.ts
+++ b/packages/twenty-front/src/testing/mock-data/workflow-run.ts
@@ -37,7 +37,7 @@ export const oneSucceededWorkflowRunQueryResult = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -66,7 +66,7 @@ export const oneSucceededWorkflowRunQueryResult = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -186,7 +186,7 @@ export const oneSucceededWorkflowRunQueryResult = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -321,7 +321,7 @@ export const oneSucceededWorkflowRunQueryResult = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -4504,7 +4504,7 @@ export const oneSucceededWorkflowRunQueryResult = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -4533,7 +4533,7 @@ export const oneSucceededWorkflowRunQueryResult = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -4653,7 +4653,7 @@ export const oneSucceededWorkflowRunQueryResult = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -4788,7 +4788,7 @@ export const oneSucceededWorkflowRunQueryResult = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-front/src/testing/mock-data/workflow.ts b/packages/twenty-front/src/testing/mock-data/workflow.ts
index 2825471ab2b..417bef448d8 100644
--- a/packages/twenty-front/src/testing/mock-data/workflow.ts
+++ b/packages/twenty-front/src/testing/mock-data/workflow.ts
@@ -272,7 +272,7 @@ export const workflowQueryResult = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/utils/prefill-workflows.util.ts b/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/utils/prefill-workflows.util.ts
index 371b9c3ad97..29bd8d6db79 100644
--- a/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/utils/prefill-workflows.util.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/utils/prefill-workflows.util.ts
@@ -381,7 +381,7 @@ export const prefillWorkflows = async (
},
},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -424,7 +424,7 @@ export const prefillWorkflows = async (
}),
},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -461,7 +461,7 @@ export const prefillWorkflows = async (
}),
},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -497,7 +497,7 @@ export const prefillWorkflows = async (
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -541,7 +541,7 @@ export const prefillWorkflows = async (
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -585,7 +585,7 @@ export const prefillWorkflows = async (
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -633,7 +633,7 @@ export const prefillWorkflows = async (
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -676,7 +676,7 @@ export const prefillWorkflows = async (
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -731,7 +731,7 @@ export const prefillWorkflows = async (
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -761,7 +761,7 @@ export const prefillWorkflows = async (
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -794,7 +794,7 @@ export const prefillWorkflows = async (
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
@@ -825,7 +825,7 @@ export const prefillWorkflows = async (
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/utils/__tests__/compute-workflow-version-step-changes.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/utils/__tests__/compute-workflow-version-step-changes.util.spec.ts
index b8bc3d1a95f..3a7ab2584e9 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/utils/__tests__/compute-workflow-version-step-changes.util.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/utils/__tests__/compute-workflow-version-step-changes.util.spec.ts
@@ -25,7 +25,7 @@ describe('computeWorkflowVersionStepChanges', () => {
input: [],
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -49,7 +49,7 @@ describe('computeWorkflowVersionStepChanges', () => {
},
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -105,7 +105,7 @@ describe('computeWorkflowVersionStepChanges', () => {
},
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/__tests__/insert-step.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/__tests__/insert-step.spec.ts
index bfa4830c2b1..3e2708c702f 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/__tests__/insert-step.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/__tests__/insert-step.spec.ts
@@ -23,7 +23,7 @@ const mockIteratorStep: WorkflowIteratorAction = {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -45,7 +45,7 @@ describe('insertStep', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/__tests__/remove-step.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/__tests__/remove-step.spec.ts
index a9aad9d1af3..4905845c3a7 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/__tests__/remove-step.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/__tests__/remove-step.spec.ts
@@ -33,7 +33,7 @@ describe('removeStep', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -185,7 +185,7 @@ describe('removeStep', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -251,7 +251,7 @@ describe('removeStep', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -316,7 +316,7 @@ describe('removeStep', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
@@ -365,7 +365,7 @@ describe('removeStep', () => {
},
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/remove-step.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/remove-step.ts
index a5f0628cffe..608a026de40 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/remove-step.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/utils/remove-step.ts
@@ -71,7 +71,7 @@ const createReplacementEmptyNode = ({
outputSchema: {},
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
input: {},
},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts
index 8b7840c8b72..cba17c8c80f 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts
@@ -59,7 +59,7 @@ const BASE_STEP_DEFINITION: BaseWorkflowActionSettings = {
value: false,
},
retryOnFailure: {
- value: false,
+ value: 0,
},
},
};
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/types/workflow-action-output.type.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/types/workflow-action-output.type.ts
index 85d71d75f3f..4d909ed6239 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/types/workflow-action-output.type.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/types/workflow-action-output.type.ts
@@ -1,6 +1,7 @@
export type WorkflowActionOutput = {
result?: object;
error?: string;
+ isUserError?: boolean;
pendingEvent?: boolean;
shouldEndWorkflowRun?: boolean;
shouldRemainRunning?: boolean;
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/get-step-retry-delay-ms.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/get-step-retry-delay-ms.util.spec.ts
new file mode 100644
index 00000000000..72dcfe69061
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/get-step-retry-delay-ms.util.spec.ts
@@ -0,0 +1,27 @@
+import { StepStatus, STEP_RETRY_DELAYS_MS } from 'twenty-shared/workflow';
+
+import { getStepRetryDelayMs } from 'src/modules/workflow/workflow-executor/utils/get-step-retry-delay-ms.util';
+
+describe('getStepRetryDelayMs', () => {
+ it('should return the first delay before any failed attempt', () => {
+ const result = getStepRetryDelayMs({
+ stepInfo: { status: StepStatus.RUNNING },
+ });
+
+ expect(result).toBe(STEP_RETRY_DELAYS_MS[0]);
+ });
+
+ it('should return the next delay for each recorded failed attempt', () => {
+ const result = getStepRetryDelayMs({
+ stepInfo: {
+ status: StepStatus.RUNNING,
+ history: [
+ { status: StepStatus.FAILED, error: 'first', retryAttempt: 1 },
+ { status: StepStatus.FAILED, error: 'second', retryAttempt: 2 },
+ ],
+ },
+ });
+
+ expect(result).toBe(STEP_RETRY_DELAYS_MS[2]);
+ });
+});
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/should-execute-child-step.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/should-execute-child-step.util.spec.ts
index 58d50144e4d..9df2eff026c 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/should-execute-child-step.util.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/should-execute-child-step.util.spec.ts
@@ -14,7 +14,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -26,7 +26,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -109,7 +109,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -121,7 +121,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -133,7 +133,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -322,7 +322,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -353,7 +353,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -400,7 +400,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -412,7 +412,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -424,7 +424,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -454,7 +454,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -504,7 +504,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -534,7 +534,7 @@ describe('shouldExecuteChildStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/should-execute-step.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/should-execute-step.util.spec.ts
index c25ea73e602..8122da01de6 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/should-execute-step.util.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/should-execute-step.util.spec.ts
@@ -16,7 +16,7 @@ describe('shouldExecuteStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
nextStepIds: ['step-3'],
@@ -27,7 +27,7 @@ describe('shouldExecuteStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
nextStepIds: ['step-3'],
@@ -38,7 +38,7 @@ describe('shouldExecuteStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
nextStepIds: [],
@@ -248,7 +248,7 @@ describe('shouldExecuteStep', () => {
},
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
@@ -302,7 +302,7 @@ describe('shouldExecuteStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
nextStepIds: ['step-3'],
@@ -314,7 +314,7 @@ describe('shouldExecuteStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
nextStepIds: [],
@@ -369,7 +369,7 @@ describe('shouldExecuteStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
nextStepIds: ['step-4'],
@@ -380,7 +380,7 @@ describe('shouldExecuteStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
nextStepIds: ['step-4'],
@@ -391,7 +391,7 @@ describe('shouldExecuteStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
nextStepIds: ['step-4'],
@@ -402,7 +402,7 @@ describe('shouldExecuteStep', () => {
settings: {
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
nextStepIds: [],
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/step-has-retry-attempts-left.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/step-has-retry-attempts-left.util.spec.ts
new file mode 100644
index 00000000000..ed7ed02ca03
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/step-has-retry-attempts-left.util.spec.ts
@@ -0,0 +1,74 @@
+import { StepStatus, STEP_RETRY_DELAYS_MS } from 'twenty-shared/workflow';
+
+import { createMockCodeStep } from 'src/modules/workflow/workflow-executor/utils/create-mock-workflow-steps.util';
+import { stepHasRetryAttemptsLeft } from 'src/modules/workflow/workflow-executor/utils/step-has-retry-attempts-left.util';
+
+describe('stepHasRetryAttemptsLeft', () => {
+ it('should return false when the step does not retry on failure', () => {
+ const result = stepHasRetryAttemptsLeft({
+ step: createMockCodeStep('step-1'),
+ stepInfo: { status: StepStatus.RUNNING },
+ });
+
+ expect(result).toBe(false);
+ });
+
+ it('should return true while attempts remain', () => {
+ const result = stepHasRetryAttemptsLeft({
+ step: createMockCodeStep('step-1', [], { retryOnFailure: 3 }),
+ stepInfo: {
+ status: StepStatus.RUNNING,
+ history: [
+ { status: StepStatus.FAILED, error: 'first', retryAttempt: 1 },
+ ],
+ },
+ });
+
+ expect(result).toBe(true);
+ });
+
+ it('should return false once the configured count is reached', () => {
+ const result = stepHasRetryAttemptsLeft({
+ step: createMockCodeStep('step-1', [], { retryOnFailure: 1 }),
+ stepInfo: {
+ status: StepStatus.RUNNING,
+ history: [
+ { status: StepStatus.FAILED, error: 'first', retryAttempt: 1 },
+ ],
+ },
+ });
+
+ expect(result).toBe(false);
+ });
+
+ it('should restart the budget on the iteration archived after a retried one', () => {
+ const result = stepHasRetryAttemptsLeft({
+ step: createMockCodeStep('step-1', [], { retryOnFailure: 1 }),
+ stepInfo: {
+ status: StepStatus.RUNNING,
+ history: [
+ { status: StepStatus.FAILED, error: 'first', retryAttempt: 1 },
+ { status: StepStatus.FAILED_SAFELY, error: 'previous iteration' },
+ ],
+ },
+ });
+
+ expect(result).toBe(true);
+ });
+
+ it('should clamp the configured count to the delay schedule length', () => {
+ const result = stepHasRetryAttemptsLeft({
+ step: createMockCodeStep('step-1', [], { retryOnFailure: 10 }),
+ stepInfo: {
+ status: StepStatus.RUNNING,
+ history: STEP_RETRY_DELAYS_MS.map((_, index) => ({
+ status: StepStatus.FAILED,
+ error: 'some error',
+ retryAttempt: index + 1,
+ })),
+ },
+ });
+
+ expect(result).toBe(false);
+ });
+});
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/step-is-awaiting-retry.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/step-is-awaiting-retry.util.spec.ts
new file mode 100644
index 00000000000..29a416de0d0
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/step-is-awaiting-retry.util.spec.ts
@@ -0,0 +1,33 @@
+import { StepStatus } from 'twenty-shared/workflow';
+
+import { createMockCodeStep } from 'src/modules/workflow/workflow-executor/utils/create-mock-workflow-steps.util';
+import { stepIsAwaitingRetry } from 'src/modules/workflow/workflow-executor/utils/step-is-awaiting-retry.util';
+
+describe('stepIsAwaitingRetry', () => {
+ it('should return true when a retrying step is pending with an error', () => {
+ const result = stepIsAwaitingRetry({
+ step: createMockCodeStep('step-1', [], { retryOnFailure: 3 }),
+ stepInfo: { status: StepStatus.PENDING, error: 'some error' },
+ });
+
+ expect(result).toBe(true);
+ });
+
+ it('should return false when the step is pending without an error', () => {
+ const result = stepIsAwaitingRetry({
+ step: createMockCodeStep('step-1', [], { retryOnFailure: 3 }),
+ stepInfo: { status: StepStatus.PENDING },
+ });
+
+ expect(result).toBe(false);
+ });
+
+ it('should return false when the step does not retry on failure', () => {
+ const result = stepIsAwaitingRetry({
+ step: createMockCodeStep('step-1'),
+ stepInfo: { status: StepStatus.PENDING, error: 'some error' },
+ });
+
+ expect(result).toBe(false);
+ });
+});
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/create-mock-workflow-steps.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/create-mock-workflow-steps.util.ts
index 950c2d2f502..0bd7a401f8c 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/create-mock-workflow-steps.util.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/create-mock-workflow-steps.util.ts
@@ -15,7 +15,10 @@ import {
export const createMockCodeStep = (
id: string,
nextStepIds: string[] = [],
- { continueOnFailure = false }: { continueOnFailure?: boolean } = {},
+ {
+ continueOnFailure = false,
+ retryOnFailure = 0,
+ }: { continueOnFailure?: boolean; retryOnFailure?: number } = {},
): WorkflowCodeAction => ({
id,
name: `Step ${id}`,
@@ -27,7 +30,7 @@ export const createMockCodeStep = (
outputSchema: {},
errorHandlingOptions: {
continueOnFailure: { value: continueOnFailure },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: retryOnFailure },
},
} as WorkflowCodeActionSettings,
});
@@ -51,7 +54,7 @@ export const createMockIteratorStep = (
outputSchema: {},
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
},
});
@@ -76,7 +79,7 @@ export const createMockIfElseStep = (
outputSchema: {},
errorHandlingOptions: {
continueOnFailure: { value: continueOnFailure },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
} as WorkflowIfElseActionSettings,
});
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/get-step-configured-retry-count.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/get-step-configured-retry-count.util.ts
new file mode 100644
index 00000000000..43befd647b7
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/get-step-configured-retry-count.util.ts
@@ -0,0 +1,4 @@
+import { type WorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
+
+export const getStepConfiguredRetryCount = (step: WorkflowAction): number =>
+ Number(step.settings.errorHandlingOptions.retryOnFailure.value) || 0;
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/get-step-retry-attempt.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/get-step-retry-attempt.util.ts
new file mode 100644
index 00000000000..511e03624ab
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/get-step-retry-attempt.util.ts
@@ -0,0 +1,11 @@
+import { type WorkflowRunStepInfo } from 'twenty-shared/workflow';
+
+export const getStepRetryAttempt = ({
+ stepInfo,
+}: {
+ stepInfo?: WorkflowRunStepInfo;
+}): number => {
+ const history = stepInfo?.history ?? [];
+
+ return history[history.length - 1]?.retryAttempt ?? 0;
+};
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/get-step-retry-delay-ms.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/get-step-retry-delay-ms.util.ts
new file mode 100644
index 00000000000..9f7479770e7
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/get-step-retry-delay-ms.util.ts
@@ -0,0 +1,12 @@
+import {
+ STEP_RETRY_DELAYS_MS,
+ type WorkflowRunStepInfo,
+} from 'twenty-shared/workflow';
+
+import { getStepRetryAttempt } from 'src/modules/workflow/workflow-executor/utils/get-step-retry-attempt.util';
+
+export const getStepRetryDelayMs = ({
+ stepInfo,
+}: {
+ stepInfo?: WorkflowRunStepInfo;
+}): number => STEP_RETRY_DELAYS_MS[getStepRetryAttempt({ stepInfo })];
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/step-has-retry-attempts-left.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/step-has-retry-attempts-left.util.ts
new file mode 100644
index 00000000000..c8b25c6ea06
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/step-has-retry-attempts-left.util.ts
@@ -0,0 +1,23 @@
+import {
+ STEP_RETRY_DELAYS_MS,
+ type WorkflowRunStepInfo,
+} from 'twenty-shared/workflow';
+
+import { getStepConfiguredRetryCount } from 'src/modules/workflow/workflow-executor/utils/get-step-configured-retry-count.util';
+import { getStepRetryAttempt } from 'src/modules/workflow/workflow-executor/utils/get-step-retry-attempt.util';
+import { type WorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
+
+export const stepHasRetryAttemptsLeft = ({
+ step,
+ stepInfo,
+}: {
+ step: WorkflowAction;
+ stepInfo?: WorkflowRunStepInfo;
+}): boolean => {
+ const maxRetryAttempts = Math.min(
+ getStepConfiguredRetryCount(step),
+ STEP_RETRY_DELAYS_MS.length,
+ );
+
+ return getStepRetryAttempt({ stepInfo }) < maxRetryAttempts;
+};
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/step-is-awaiting-retry.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/step-is-awaiting-retry.util.ts
new file mode 100644
index 00000000000..0789f9546e4
--- /dev/null
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/step-is-awaiting-retry.util.ts
@@ -0,0 +1,16 @@
+import { isDefined } from 'twenty-shared/utils';
+import { StepStatus, type WorkflowRunStepInfo } from 'twenty-shared/workflow';
+
+import { getStepConfiguredRetryCount } from 'src/modules/workflow/workflow-executor/utils/get-step-configured-retry-count.util';
+import { type WorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
+
+export const stepIsAwaitingRetry = ({
+ step,
+ stepInfo,
+}: {
+ step: WorkflowAction;
+ stepInfo?: WorkflowRunStepInfo;
+}): boolean =>
+ stepInfo?.status === StepStatus.PENDING &&
+ isDefined(stepInfo.error) &&
+ getStepConfiguredRetryCount(step) > 0;
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/http-request/__tests__/http-request.workflow-action.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/http-request/__tests__/http-request.workflow-action.spec.ts
index 9b831cc91c5..60b28df8b09 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/http-request/__tests__/http-request.workflow-action.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/http-request/__tests__/http-request.workflow-action.spec.ts
@@ -10,7 +10,7 @@ import { WorkflowRunStepLogWorkspaceService } from 'src/modules/workflow/workflo
const baseSettings: WorkflowActionSettings = {
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
input: {},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/__tests__/iterator-action.workflow-action.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/__tests__/iterator-action.workflow-action.spec.ts
index 0fba9e256ab..f44df6c6310 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/__tests__/iterator-action.workflow-action.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/__tests__/iterator-action.workflow-action.spec.ts
@@ -21,7 +21,7 @@ describe('IteratorWorkflowAction', () => {
const baseSettings: WorkflowActionSettings = {
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
input: {
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/__tests__/should-execute-iterator-step.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/__tests__/should-execute-iterator-step.util.spec.ts
index f5e95337745..b807f8bbd14 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/__tests__/should-execute-iterator-step.util.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/__tests__/should-execute-iterator-step.util.spec.ts
@@ -479,7 +479,7 @@ describe('shouldExecuteIteratorStep', () => {
},
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/__tests__/should-skip-iterator-step-execution.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/__tests__/should-skip-iterator-step-execution.util.spec.ts
index 00e3249c289..09d68b9be0a 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/__tests__/should-skip-iterator-step-execution.util.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/iterator/utils/__tests__/should-skip-iterator-step-execution.util.spec.ts
@@ -419,7 +419,7 @@ describe('shouldSkipIteratorStepExecution', () => {
},
errorHandlingOptions: {
continueOnFailure: { value: false },
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
},
outputSchema: {},
},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/__tests__/draft-email.workflow-action.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/__tests__/draft-email.workflow-action.spec.ts
index 42ce9208ad4..7023c2cd5d9 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/__tests__/draft-email.workflow-action.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/__tests__/draft-email.workflow-action.spec.ts
@@ -14,7 +14,7 @@ import { WorkflowRunStepLogWorkspaceService } from 'src/modules/workflow/workflo
const baseSettings: WorkflowActionSettings = {
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
input: {},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/__tests__/send-email.workflow-action.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/__tests__/send-email.workflow-action.spec.ts
index 467141b1e53..c88c557c372 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/__tests__/send-email.workflow-action.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/__tests__/send-email.workflow-action.spec.ts
@@ -14,7 +14,7 @@ import { WorkflowRunStepLogWorkspaceService } from 'src/modules/workflow/workflo
const baseSettings: WorkflowActionSettings = {
outputSchema: {},
errorHandlingOptions: {
- retryOnFailure: { value: false },
+ retryOnFailure: { value: 0 },
continueOnFailure: { value: false },
},
input: {},
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action-settings.type.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action-settings.type.ts
index d2a1288ef33..ac21642cda3 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action-settings.type.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action-settings.type.ts
@@ -23,7 +23,7 @@ export type BaseWorkflowActionSettings = {
outputSchema: OutputSchema;
errorHandlingOptions: {
retryOnFailure: {
- value: boolean;
+ value: number;
};
continueOnFailure: {
value: boolean;
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts
index baf5e0e5b75..6e81bf5c44c 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts
@@ -34,6 +34,9 @@ import {
type WorkflowBranchExecutorInput,
type WorkflowExecutorInput,
} from 'src/modules/workflow/workflow-executor/types/workflow-executor-input';
+import { getStepRetryAttempt } from 'src/modules/workflow/workflow-executor/utils/get-step-retry-attempt.util';
+import { getStepRetryDelayMs } from 'src/modules/workflow/workflow-executor/utils/get-step-retry-delay-ms.util';
+import { stepHasRetryAttemptsLeft } from 'src/modules/workflow/workflow-executor/utils/step-has-retry-attempts-left.util';
import { shouldExecuteStep } from 'src/modules/workflow/workflow-executor/utils/should-execute-step.util';
import { shouldFailSafely } from 'src/modules/workflow/workflow-executor/utils/should-fail-safely.util';
import { shouldSkipStepExecution } from 'src/modules/workflow/workflow-executor/utils/should-skip-step-execution.util';
@@ -142,6 +145,26 @@ export class WorkflowExecutorWorkspaceService {
workspaceId,
});
+ if (isDefined(actionOutput.error) && !actionOutput.isUserError) {
+ const canRetryStep = stepHasRetryAttemptsLeft({
+ step: stepToExecute,
+ stepInfo: stepInfos[stepId],
+ });
+
+ if (canRetryStep) {
+ await this.scheduleStepRetry({
+ stepId,
+ stepInfo: stepInfos[stepId],
+ error: actionOutput.error,
+ retryDelayMs: getStepRetryDelayMs({ stepInfo: stepInfos[stepId] }),
+ workflowRunId,
+ workspaceId,
+ });
+
+ return;
+ }
+ }
+
if (isDefined(actionOutput.error)) {
const enclosingIterator = findEnclosingIteratorWithContinueOnFailure({
failedStepId: stepId,
@@ -483,6 +506,7 @@ export class WorkflowExecutorWorkspaceService {
return {
error: error.message ?? 'Execution result error, no data or error',
+ isUserError,
};
}
}
@@ -589,6 +613,61 @@ export class WorkflowExecutorWorkspaceService {
}
}
+ private async scheduleStepRetry({
+ stepId,
+ stepInfo,
+ error,
+ retryDelayMs,
+ workflowRunId,
+ workspaceId,
+ }: {
+ stepId: string;
+ stepInfo?: WorkflowRunStepInfo;
+ error: string;
+ retryDelayMs: number;
+ workflowRunId: string;
+ workspaceId: string;
+ }) {
+ await this.workflowRunWorkspaceService.updateWorkflowRunStepInfos({
+ stepInfos: {
+ [stepId]: {
+ status: StepStatus.PENDING,
+ error,
+ history: [
+ ...(stepInfo?.history ?? []),
+ {
+ status: StepStatus.FAILED,
+ error,
+ retryAttempt: getStepRetryAttempt({ stepInfo }) + 1,
+ },
+ ],
+ },
+ },
+ workflowRunId,
+ workspaceId,
+ });
+
+ try {
+ await this.messageQueueService.add<RunWorkflowJobData>(
+ RUN_WORKFLOW_JOB_NAME,
+ {
+ workspaceId,
+ workflowRunId,
+ stepIdsToRetry: [stepId],
+ },
+ { ...buildRunWorkflowJobOptions(workflowRunId), delay: retryDelayMs },
+ );
+ } catch (enqueueError) {
+ await this.workflowRunWorkspaceService.updateWorkflowRunStepInfos({
+ stepInfos: { [stepId]: { status: StepStatus.FAILED, error } },
+ workflowRunId,
+ workspaceId,
+ });
+
+ throw enqueueError;
+ }
+ }
+
private async continueExecutionFromStepInAnotherJob({
lastExecutedStepId,
workflowRunId,
diff --git a/packages/twenty-server/src/modules/workflow/workflow-runner/jobs/run-workflow.job.ts b/packages/twenty-server/src/modules/workflow/workflow-runner/jobs/run-workflow.job.ts
index 019cef51a7c..fe8bfca84b4 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-runner/jobs/run-workflow.job.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-runner/jobs/run-workflow.job.ts
@@ -1,6 +1,7 @@
import { Logger, Scope } from '@nestjs/common';
import { isDefined } from 'twenty-shared/utils';
+import { StepStatus } from 'twenty-shared/workflow';
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';
import { Processor } from 'src/engine/core-modules/message-queue/decorators/processor.decorator';
@@ -12,6 +13,7 @@ import { buildSystemAuthContext } from 'src/engine/twenty-orm/utils/build-system
import { WorkflowRunStatus } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';
import { WorkflowCommonWorkspaceService } from 'src/modules/workflow/common/workspace-services/workflow-common.workspace-service';
import { CodeStepBuildService } from 'src/modules/workflow/workflow-builder/workflow-version-step/code-step/services/code-step-build.service';
+import { stepIsAwaitingRetry } from 'src/modules/workflow/workflow-executor/utils/step-is-awaiting-retry.util';
import { WorkflowExecutorWorkspaceService } from 'src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service';
import { RUN_WORKFLOW_JOB_NAME } from 'src/modules/workflow/workflow-runner/constants/run-workflow-job-name';
import {
@@ -157,6 +159,34 @@ export class RunWorkflowJob {
return;
}
+ const steps = workflowRun.state?.flow?.steps ?? [];
+ const stepInfos = workflowRun.state?.stepInfos ?? {};
+
+ const stepInfosToReset = Object.fromEntries(
+ stepIdsToRetry
+ .map((stepId) => ({
+ stepId,
+ step: steps.find((candidateStep) => candidateStep.id === stepId),
+ }))
+ .filter(
+ ({ step, stepId }) =>
+ isDefined(step) &&
+ stepIsAwaitingRetry({ step, stepInfo: stepInfos[stepId] }),
+ )
+ .map(({ stepId }) => [
+ stepId,
+ { ...stepInfos[stepId], status: StepStatus.NOT_STARTED },
+ ]),
+ );
+
+ if (Object.keys(stepInfosToReset).length > 0) {
+ await this.workflowRunWorkspaceService.updateWorkflowRunStepInfos({
+ stepInfos: stepInfosToReset,
+ workflowRunId,
+ workspaceId,
+ });
+ }
+
await this.workflowExecutorWorkspaceService.executeFromSteps({
stepIds: stepIdsToRetry,
workflowRunId,
diff --git a/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/__tests__/assert-form-step-is-valid.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/__tests__/assert-form-step-is-valid.util.spec.ts
index 372beafe749..f26f2460510 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/__tests__/assert-form-step-is-valid.util.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/__tests__/assert-form-step-is-valid.util.spec.ts
@@ -58,7 +58,7 @@ const settings: WorkflowFormActionSettings = {
},
errorHandlingOptions: {
retryOnFailure: {
- value: false,
+ value: 0,
},
continueOnFailure: {
value: false,
diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/continue-on-failure-workflow.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/step-error-handling-workflow.integration-spec.ts
similarity index 84%
rename from packages/twenty-server/test/integration/graphql/suites/workflow/continue-on-failure-workflow.integration-spec.ts
rename to packages/twenty-server/test/integration/graphql/suites/workflow/step-error-handling-workflow.integration-spec.ts
index 87764cb6cd2..c7bf989dfc4 100644
--- a/packages/twenty-server/test/integration/graphql/suites/workflow/continue-on-failure-workflow.integration-spec.ts
+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/step-error-handling-workflow.integration-spec.ts
@@ -1,3 +1,4 @@
+import { STEP_RETRY_DELAYS_MS } from 'twenty-shared/workflow';
import request from 'supertest';
import {
destroyWorkflowRun,
@@ -15,7 +16,14 @@ const client = request(`http://localhost:${APP_PORT}`);
const BLOCKED_REQUEST_URL = 'http://127.0.0.1:1/';
-describe('Continue on failure workflow (e2e)', () => {
+const TOTAL_RETRY_DELAY_MS = STEP_RETRY_DELAYS_MS.reduce(
+ (total, delay) => total + delay,
+ 0,
+);
+
+const RETRY_TEST_TIMEOUT_MS = TOTAL_RETRY_DELAY_MS + 60_000;
+
+describe('Step error handling workflow (e2e)', () => {
let createdWorkflowId: string | null = null;
let createdWorkflowVersionId: string | null = null;
let httpRequestStepId: string | null = null;
@@ -75,8 +83,10 @@ describe('Continue on failure workflow (e2e)', () => {
const setUpFailingHttpRequestStep = async ({
continueOnFailure,
+ retryOnFailure = 0,
}: {
continueOnFailure: boolean;
+ retryOnFailure?: number;
}) => {
const steps = await getSteps();
@@ -109,6 +119,7 @@ describe('Continue on failure workflow (e2e)', () => {
errorHandlingOptions: {
...httpRequestStep.settings.errorHandlingOptions,
continueOnFailure: { value: continueOnFailure },
+ retryOnFailure: { value: retryOnFailure },
},
},
},
@@ -261,4 +272,37 @@ describe('Continue on failure workflow (e2e)', () => {
await destroyWorkflowRun(workflowRunId);
}
});
+ it(
+ 'should retry the failing step before failing the run when the step retries on failure',
+ async () => {
+ await setUpFailingHttpRequestStep({
+ continueOnFailure: false,
+ retryOnFailure: STEP_RETRY_DELAYS_MS.length,
+ });
+
+ const workflowRunId = await runWorkflowVersion({
+ workflowVersionId: createdWorkflowVersionId!,
+ });
+
+ try {
+ const workflowRun = await waitForWorkflowCompletion(
+ workflowRunId,
+ Math.ceil(TOTAL_RETRY_DELAY_MS / 500) + 60,
+ );
+
+ expect(workflowRun?.status).toBe('FAILED');
+
+ const httpRequestStepInfo =
+ workflowRun?.state?.stepInfos?.[httpRequestStepId!];
+
+ expect(httpRequestStepInfo?.status).toBe('FAILED');
+ expect(httpRequestStepInfo?.history).toHaveLength(
+ STEP_RETRY_DELAYS_MS.length,
+ );
+ } finally {
+ await destroyWorkflowRun(workflowRunId);
+ }
+ },
+ RETRY_TEST_TIMEOUT_MS,
+ );
});
diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-run-test.util.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-run-test.util.ts
index c5ff5941e69..389d08da908 100644
--- a/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-run-test.util.ts
+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-run-test.util.ts
@@ -19,6 +19,7 @@ export type WorkflowRunState = {
status: string;
result?: Record<string, unknown>;
error?: string;
+ history?: Array<{ status: string; error?: string }>;
}
>;
flow?: {
diff --git a/packages/twenty-shared/src/workflow/constants/StepRetryDelaysMs.ts b/packages/twenty-shared/src/workflow/constants/StepRetryDelaysMs.ts
new file mode 100644
index 00000000000..cb0f66f6465
--- /dev/null
+++ b/packages/twenty-shared/src/workflow/constants/StepRetryDelaysMs.ts
@@ -0,0 +1 @@
+export const STEP_RETRY_DELAYS_MS = [1_000, 5_000, 15_000];
diff --git a/packages/twenty-shared/src/workflow/index.ts b/packages/twenty-shared/src/workflow/index.ts
index 0e29cb1c452..d553cb14494 100644
--- a/packages/twenty-shared/src/workflow/index.ts
+++ b/packages/twenty-shared/src/workflow/index.ts
@@ -11,6 +11,7 @@ export { CAPTURE_ALL_VARIABLE_TAG_INNER_REGEX } from './constants/CaptureAllVari
export { CONTENT_TYPE_VALUES_HTTP_REQUEST } from './constants/ContentTypeValuesHttpRequest';
export { IF_ELSE_BRANCH_POSITION_OFFSETS } from './constants/IfElseBranchPositionOffsets';
export { OBJECTS_BLOCKED_FROM_AUTOMATION } from './constants/ObjectsBlockedFromAutomation';
+export { STEP_RETRY_DELAYS_MS } from './constants/StepRetryDelaysMs';
export { TRIGGER_STEP_ID } from './constants/TriggerStepId';
export { WORKFLOW_TRIGGER_METADATA_KEY } from './constants/WorkflowTriggerMetadataKey';
export { WORKFLOW_TRIGGER_METADATA_LABEL } from './constants/WorkflowTriggerMetadataLabel';
diff --git a/packages/twenty-shared/src/workflow/schemas/base-workflow-action-settings-schema.ts b/packages/twenty-shared/src/workflow/schemas/base-workflow-action-settings-schema.ts
index 8be2e85b536..efd3f981673 100644
--- a/packages/twenty-shared/src/workflow/schemas/base-workflow-action-settings-schema.ts
+++ b/packages/twenty-shared/src/workflow/schemas/base-workflow-action-settings-schema.ts
@@ -1,5 +1,7 @@
import { z } from 'zod';
+import { STEP_RETRY_DELAYS_MS } from '@/workflow/constants/StepRetryDelaysMs';
+
export const baseWorkflowActionSettingsSchema = z.object({
input: z
.looseObject({})
@@ -13,7 +15,17 @@ export const baseWorkflowActionSettingsSchema = z.object({
),
errorHandlingOptions: z.object({
retryOnFailure: z.object({
- value: z.boolean().describe('Whether to retry the action if it fails.'),
+ value: z.preprocess(
+ (value) => (typeof value === 'boolean' ? Number(value) : value),
+ z
+ .number()
+ .int()
+ .min(0)
+ .max(STEP_RETRY_DELAYS_MS.length)
+ .describe(
+ `How many times to retry the action if it fails, between 0 and ${STEP_RETRY_DELAYS_MS.length}. 0 disables retries.`,
+ ),
+ ),
}),
continueOnFailure: z.object({
value: z
diff --git a/packages/twenty-shared/src/workflow/schemas/workflow-run-state-step-info-schema.ts b/packages/twenty-shared/src/workflow/schemas/workflow-run-state-step-info-schema.ts
index 2446ab141a0..2afb3639c31 100644
--- a/packages/twenty-shared/src/workflow/schemas/workflow-run-state-step-info-schema.ts
+++ b/packages/twenty-shared/src/workflow/schemas/workflow-run-state-step-info-schema.ts
@@ -5,6 +5,7 @@ export const workflowRunStateStepInfoSchema = z.object({
result: z.any().optional(),
error: z.any().optional(),
status: workflowRunStepStatusSchema,
+ retryAttempt: z.number().optional(),
get history() {
return z
.array(
@@ -12,6 +13,7 @@ export const workflowRunStateStepInfoSchema = z.object({
result: true,
status: true,
error: true,
+ retryAttempt: true,
}),
)
.optional();
diff --git a/packages/twenty-shared/src/workflow/validation/__tests__/validate-workflow-structure.util.test.ts b/packages/twenty-shared/src/workflow/validation/__tests__/validate-workflow-structure.util.test.ts
index 47cf8c5ef0d..c010e23a924 100644
--- a/packages/twenty-shared/src/workflow/validation/__tests__/validate-workflow-structure.util.test.ts
+++ b/packages/twenty-shared/src/workflow/validation/__tests__/validate-workflow-structure.util.test.ts
@@ -46,4 +46,33 @@ describe('validateWorkflowStructure', () => {
'UNREACHABLE_STEP',
);
});
+ it('should accept a step whose retryOnFailure value is a legacy boolean', () => {
+ const legacyBooleanStep = {
+ id: '11111111-1111-4111-8111-111111111111',
+ name: 'Code step',
+ type: 'CODE',
+ valid: true,
+ nextStepIds: [],
+ settings: {
+ input: { logicFunctionId: 'fn-1', logicFunctionInput: {} },
+ outputSchema: {},
+ errorHandlingOptions: {
+ retryOnFailure: { value: true },
+ continueOnFailure: { value: false },
+ },
+ },
+ };
+
+ const result = validateWorkflowStructure({
+ trigger: {
+ type: 'MANUAL',
+ nextStepIds: ['11111111-1111-4111-8111-111111111111'],
+ },
+ steps: [legacyBooleanStep],
+ });
+
+ expect(
+ result.errors.filter((issue) => issue.code === 'INVALID_STEP_PARAMS'),
+ ).toEqual([]);
+ });
});