fix: Fix resolving of expressions of deeply nested sub-nodes (#8612)
This commit is contained in:
@@ -73,41 +73,6 @@ import { useI18n } from '@/composables/useI18n';
|
||||
import type { Router } from 'vue-router';
|
||||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
|
||||
export function getParentMainInputNode(workflow: Workflow, node: INode): INode {
|
||||
const nodeType = useNodeTypesStore().getNodeType(node.type);
|
||||
if (nodeType) {
|
||||
const outputs = NodeHelpers.getNodeOutputs(workflow, node, nodeType);
|
||||
|
||||
if (!!outputs.find((output) => output !== NodeConnectionType.Main)) {
|
||||
// Get the first node which is connected to a non-main output
|
||||
const nonMainNodesConnected = outputs?.reduce((acc, outputName) => {
|
||||
const parentNodes = workflow.getChildNodes(node.name, outputName);
|
||||
if (parentNodes.length > 0) {
|
||||
acc.push(...parentNodes);
|
||||
}
|
||||
return acc;
|
||||
}, [] as string[]);
|
||||
|
||||
if (nonMainNodesConnected.length) {
|
||||
const returnNode = workflow.getNode(nonMainNodesConnected[0]);
|
||||
if (returnNode === null) {
|
||||
// This should theoretically never happen as the node is connected
|
||||
// but who knows and it makes TS happy
|
||||
throw new Error(
|
||||
`The node "${nonMainNodesConnected[0]}" which is a connection of "${node.name}" could not be found!`,
|
||||
);
|
||||
}
|
||||
|
||||
// The chain of non-main nodes is potentially not finished yet so
|
||||
// keep on going
|
||||
return getParentMainInputNode(workflow, returnNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
export function resolveParameter(
|
||||
parameter: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[],
|
||||
opts: {
|
||||
@@ -127,7 +92,7 @@ export function resolveParameter(
|
||||
const workflow = getCurrentWorkflow();
|
||||
|
||||
if (activeNode) {
|
||||
contextNode = getParentMainInputNode(workflow, activeNode);
|
||||
contextNode = workflow.getParentMainInputNode(activeNode);
|
||||
}
|
||||
|
||||
const workflowRunData = useWorkflowsStore().getWorkflowRunData;
|
||||
@@ -1187,7 +1152,6 @@ export function useWorkflowHelpers(router: Router) {
|
||||
getCurrentWorkflow,
|
||||
getConnectedNodes,
|
||||
getNodes,
|
||||
getParentMainInputNode,
|
||||
getWorkflow,
|
||||
getNodeTypes,
|
||||
connectionInputData,
|
||||
|
||||
Reference in New Issue
Block a user