From fef627b7c2d8e9c2f14c403f1bb1a9eab1053f49 Mon Sep 17 00:00:00 2001 From: Thomas Trompette Date: Tue, 29 Apr 2025 13:29:11 +0200 Subject: [PATCH] Fix output schema type not defined (#11788) Fixes https://github.com/twentyhq/twenty/issues/11778 --- .../searchVariableThroughOutputSchema.test.ts | 13 +++++++++++++ .../utils/searchVariableThroughOutputSchema.ts | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/searchVariableThroughOutputSchema.test.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/searchVariableThroughOutputSchema.test.ts index d3a35d971..39b83e81e 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/searchVariableThroughOutputSchema.test.ts +++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/searchVariableThroughOutputSchema.test.ts @@ -61,6 +61,19 @@ const mockStep = { } satisfies StepOutputSchema; describe('searchVariableThroughOutputSchema', () => { + it('should not break with wrong path', () => { + const result = searchVariableThroughOutputSchema({ + stepOutputSchema: mockStep, + rawVariableName: '{{step-1.wrong.wrong.wrong}}', + isFullRecord: false, + }); + + expect(result).toEqual({ + variableLabel: undefined, + variablePathLabel: 'Step 1 > undefined', + }); + }); + it('should find a company field variable', () => { const result = searchVariableThroughOutputSchema({ stepOutputSchema: mockStep, diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/searchVariableThroughOutputSchema.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/searchVariableThroughOutputSchema.ts index 0e7e2a774..899bf8813 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/searchVariableThroughOutputSchema.ts +++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/searchVariableThroughOutputSchema.ts @@ -47,7 +47,9 @@ const searchCurrentStepOutputSchema = ({ let variablePathLabel = stepOutputSchema.name; while (nextKeyIndex < path.length) { - if (isRecordOutputSchema(currentSubStep)) { + if (!isDefined(currentSubStep)) { + break; + } else if (isRecordOutputSchema(currentSubStep)) { const currentField = currentSubStep.fields[nextKey]; currentSubStep = currentField?.value; nextKey = path[nextKeyIndex + 1];