mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Handle connections for missing nodes in a workflow (#13362)
This commit is contained in:
parent
6ef9ae1862
commit
1e5feb195d
|
@ -508,6 +508,9 @@ export class Workflow {
|
|||
return;
|
||||
}
|
||||
|
||||
// Ignore connections for nodes that don't exist in this workflow
|
||||
if (!(connection.node in this.nodes)) return;
|
||||
|
||||
addNodes = this.getHighestNode(connection.node, undefined, checkedNodes);
|
||||
|
||||
if (addNodes.length === 0) {
|
||||
|
|
|
@ -2201,7 +2201,7 @@ describe('Workflow', () => {
|
|||
expect(result).toEqual([targetNode.name]);
|
||||
});
|
||||
|
||||
test('should handle connections to nodes not defined in workflow', () => {
|
||||
test('should handle connections to nodes that are not defined in the workflow', () => {
|
||||
const node1 = createNode('Node1');
|
||||
const targetNode = createNode('TargetNode');
|
||||
|
||||
|
@ -2226,6 +2226,31 @@ describe('Workflow', () => {
|
|||
|
||||
expect(result).toEqual([targetNode.name]);
|
||||
});
|
||||
|
||||
test('should handle connections from nodes that are not defined in the workflow', () => {
|
||||
const node1 = createNode('Node1');
|
||||
const targetNode = createNode('TargetNode');
|
||||
|
||||
const connections = {
|
||||
Node1: {
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
},
|
||||
NonExistentNode: {
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
const workflow = new Workflow({
|
||||
id: 'test',
|
||||
nodes: [node1, targetNode],
|
||||
connections,
|
||||
active: false,
|
||||
nodeTypes,
|
||||
});
|
||||
|
||||
const result = workflow.getHighestNode(targetNode.name);
|
||||
expect(result).toEqual([node1.name]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getParentMainInputNode', () => {
|
||||
|
|
Loading…
Reference in a new issue