fix(core): Handle connections for missing nodes in a workflow (#13362)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2025-02-19 16:56:44 +01:00 committed by GitHub
parent 6ef9ae1862
commit 1e5feb195d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 1 deletions

View file

@ -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) {

View file

@ -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', () => {