mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-09-05 01:56:33 +02:00
fix(core): Error in partial execution of vector stores (#15019)
This commit is contained in:
+3
-2
@@ -93,14 +93,15 @@ describe('rewireGraph()', () => {
|
||||
expect(tool.rewireOutputLogTo).toBe(NodeConnectionTypes.AiTool);
|
||||
});
|
||||
|
||||
it('fails when the tool has no incoming connections', () => {
|
||||
it('should not rewire when the tool has no root', () => {
|
||||
const tool = createNodeData({ name: 'tool', type: 'n8n-nodes-base.ai-tool' });
|
||||
const root = createNodeData({ name: 'root' });
|
||||
|
||||
const graph = new DirectedGraph();
|
||||
graph.addNodes(root, tool);
|
||||
const result = rewireGraph(tool, graph);
|
||||
|
||||
expect(() => rewireGraph(tool, graph)).toThrow();
|
||||
expect(result).toStrictEqual(graph);
|
||||
});
|
||||
|
||||
it('removes the root node from the graph', () => {
|
||||
|
||||
@@ -4,26 +4,28 @@ import { type INode, NodeConnectionTypes } from 'n8n-workflow';
|
||||
import { type DirectedGraph } from './directed-graph';
|
||||
|
||||
export function rewireGraph(tool: INode, graph: DirectedGraph): DirectedGraph {
|
||||
graph = graph.clone();
|
||||
const children = graph.getChildren(tool);
|
||||
const modifiedGraph = graph.clone();
|
||||
const children = modifiedGraph.getChildren(tool);
|
||||
|
||||
a.ok(children.size > 0, 'Tool must be connected to a root node');
|
||||
if (children.size === 0) {
|
||||
return graph;
|
||||
}
|
||||
|
||||
const rootNode = [...children][0];
|
||||
|
||||
a.ok(rootNode);
|
||||
|
||||
const allIncomingConnection = graph
|
||||
const allIncomingConnection = modifiedGraph
|
||||
.getDirectParentConnections(rootNode)
|
||||
.filter((cn) => cn.type === NodeConnectionTypes.Main);
|
||||
|
||||
tool.rewireOutputLogTo = NodeConnectionTypes.AiTool;
|
||||
|
||||
for (const cn of allIncomingConnection) {
|
||||
graph.addConnection({ from: cn.from, to: tool });
|
||||
modifiedGraph.addConnection({ from: cn.from, to: tool });
|
||||
}
|
||||
|
||||
graph.removeNode(rootNode);
|
||||
modifiedGraph.removeNode(rootNode);
|
||||
|
||||
return graph;
|
||||
return modifiedGraph;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user