diff --git a/packages/editor-ui/src/components/AssignmentCollection/Assignment.vue b/packages/editor-ui/src/components/AssignmentCollection/Assignment.vue index 963f8df08fa64..816218c27fb17 100644 --- a/packages/editor-ui/src/components/AssignmentCollection/Assignment.vue +++ b/packages/editor-ui/src/components/AssignmentCollection/Assignment.vue @@ -56,21 +56,6 @@ const assignmentTypeToNodeProperty = ( } }; -function getExpressionResult(value: string): Result { - try { - const resolvedValue = resolveExpression(value, { - targetItem: ndvStore.hoveringItem ?? undefined, - inputNodeName: ndvStore.ndvInputNodeName, - inputRunIndex: ndvStore.ndvInputRunIndex, - inputBranchIndex: ndvStore.ndvInputBranchIndex, - }) as unknown; - - return { ok: true, result: resolvedValue }; - } catch (error) { - return { ok: false, error }; - } -} - const nameParameter = computed(() => ({ name: 'name', displayName: 'Name', @@ -95,7 +80,22 @@ const hint = computed(() => { if (typeof value !== 'string' || !value.startsWith('=')) { return ''; } - return stringifyExpressionResult(getExpressionResult(value)); + + let result: Result; + try { + const resolvedValue = resolveExpression(value, undefined, { + targetItem: ndvStore.hoveringItem ?? undefined, + inputNodeName: ndvStore.ndvInputNodeName, + inputRunIndex: ndvStore.ndvInputRunIndex, + inputBranchIndex: ndvStore.ndvInputBranchIndex, + }) as unknown; + + result = { ok: true, result: resolvedValue }; + } catch (error) { + result = { ok: false, error }; + } + + return stringifyExpressionResult(result); }); const highlightHint = computed(() => diff --git a/packages/editor-ui/src/components/ParameterInputWrapper.vue b/packages/editor-ui/src/components/ParameterInputWrapper.vue index 72e00b22f2973..957b21a9ac842 100644 --- a/packages/editor-ui/src/components/ParameterInputWrapper.vue +++ b/packages/editor-ui/src/components/ParameterInputWrapper.vue @@ -197,12 +197,13 @@ export default defineComponent({ isInputParentOfActiveNode(): boolean { return this.ndvStore.isInputParentOfActiveNode; }, - evaluatedExpression(): Result { + evaluatedExpression(): Result { const value = isResourceLocatorValue(this.modelValue) ? this.modelValue.value : this.modelValue; + if (!this.activeNode || !this.isValueExpression || typeof value !== 'string') { - return { ok: false, error: '' }; + return { ok: false, error: new Error() }; } try { diff --git a/packages/editor-ui/src/utils/expressions.ts b/packages/editor-ui/src/utils/expressions.ts index 5a2bebbe5a2d8..dbab832fd670c 100644 --- a/packages/editor-ui/src/utils/expressions.ts +++ b/packages/editor-ui/src/utils/expressions.ts @@ -111,15 +111,13 @@ export const getExpressionErrorMessage = (error: Error): string => { return error.message; }; -export const stringifyExpressionResult = (result: Result): string => { +export const stringifyExpressionResult = (result: Result): string => { if (!result.ok) { if (getResolvableState(result.error) !== 'invalid') { return ''; } - return `[${i18n.baseText('parameterInput.error')}: ${getExpressionErrorMessage( - result.error as Error, - )}]`; + return `[${i18n.baseText('parameterInput.error')}: ${getExpressionErrorMessage(result.error)}]`; } if (result.result === null) {