From 0e68602030ecf6b2f18aab4d5c497bbcfc9631f2 Mon Sep 17 00:00:00 2001 From: martmull Date: Tue, 3 Jun 2025 16:50:46 +0200 Subject: [PATCH] Fix function input computation in workflow code step (#12440) As title Fix consist by awaiting for getFunctionInputFromSourceCode response --- .../hooks/useServerlessFunctionUpdateFormState.ts | 6 ++++-- .../components/WorkflowEditActionServerlessFunction.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState.ts index 432ee01e5..b89eace84 100644 --- a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState.ts +++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState.ts @@ -47,7 +47,7 @@ export const useServerlessFunctionUpdateFormState = ({ const { loading } = useGetOneServerlessFunctionSourceCode({ id: serverlessFunctionId, version: serverlessFunctionVersion, - onCompleted: (data: FindOneServerlessFunctionSourceCodeQuery) => { + onCompleted: async (data: FindOneServerlessFunctionSourceCodeQuery) => { const newState = { code: data?.getServerlessFunctionSourceCode || undefined, name: serverlessFunction?.name || '', @@ -63,9 +63,11 @@ export const useServerlessFunctionUpdateFormState = ({ const sourceCode = data?.getServerlessFunctionSourceCode?.[INDEX_FILE_PATH]; + const functionInput = await getFunctionInputFromSourceCode(sourceCode); + setServerlessFunctionTestData((prev) => ({ ...prev, - input: getFunctionInputFromSourceCode(sourceCode), + input: functionInput, shouldInitInput: false, })); } diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionServerlessFunction.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionServerlessFunction.tsx index 2b43b89cd..9f237cc85 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionServerlessFunction.tsx +++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionServerlessFunction.tsx @@ -150,7 +150,7 @@ export const WorkflowEditActionServerlessFunction = ({ return; } - const newFunctionInput = getFunctionInputFromSourceCode(sourceCode); + const newFunctionInput = await getFunctionInputFromSourceCode(sourceCode); const newMergedInput = mergeDefaultFunctionInputAndFunctionInput({ newInput: newFunctionInput, oldInput: action.settings.input.serverlessFunctionInput,