diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts index ed9ec8708be..0b5e89b2e28 100644 --- a/packages/server/src/utils/index.ts +++ b/packages/server/src/utils/index.ts @@ -777,14 +777,15 @@ export const getVariableValue = async ( flowData?: ICommonObject ) => { const isObject = typeof paramValue === 'object' - let returnVal = (isObject ? JSON.stringify(paramValue) : paramValue) ?? '' + const initialValue = (isObject ? JSON.stringify(paramValue) : paramValue) ?? '' + let returnVal = initialValue const variableStack = [] const variableDict = {} as IVariableDict let startIdx = 0 - const endIdx = returnVal.length - 1 + const endIdx = initialValue.length - 1 while (startIdx < endIdx) { - const substr = returnVal.substring(startIdx, startIdx + 2) + const substr = initialValue.substring(startIdx, startIdx + 2) // Store the opening double curly bracket if (substr === '{{') { @@ -795,7 +796,7 @@ export const getVariableValue = async ( if (substr === '}}' && variableStack.length > 0 && variableStack[variableStack.length - 1].substr === '{{') { const variableStartIdx = variableStack[variableStack.length - 1].startIdx const variableEndIdx = startIdx - const variableFullPath = returnVal.substring(variableStartIdx, variableEndIdx) + const variableFullPath = initialValue.substring(variableStartIdx, variableEndIdx) /** * Apply string transformation to convert special chars: