mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Consider pinned data as valid paths for single node execution (#17959)
This commit is contained in:
@@ -943,6 +943,12 @@ export class Workflow {
|
|||||||
hasPath(fromNodeName: string, toNodeName: string, maxDepth = 50): boolean {
|
hasPath(fromNodeName: string, toNodeName: string, maxDepth = 50): boolean {
|
||||||
if (fromNodeName === toNodeName) return true;
|
if (fromNodeName === toNodeName) return true;
|
||||||
|
|
||||||
|
// Special case: If the source node has pinned data, consider it as having a valid path
|
||||||
|
// This is important for single node execution scenarios where pinned data creates virtual paths
|
||||||
|
if (this.getPinDataOfNode(fromNodeName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Get connection types that actually exist in this workflow
|
// Get connection types that actually exist in this workflow
|
||||||
// We need both source and destination connection types for bidirectional search
|
// We need both source and destination connection types for bidirectional search
|
||||||
const connectionTypes = new Set<NodeConnectionType>();
|
const connectionTypes = new Set<NodeConnectionType>();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import type {
|
|||||||
INode,
|
INode,
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INodeParameters,
|
INodeParameters,
|
||||||
|
IPinData,
|
||||||
IRunExecutionData,
|
IRunExecutionData,
|
||||||
NodeParameterValueType,
|
NodeParameterValueType,
|
||||||
} from '../src/interfaces';
|
} from '../src/interfaces';
|
||||||
@@ -3583,5 +3584,56 @@ describe('Workflow', () => {
|
|||||||
expect(workflow.hasPath('Node1', 'Node2')).toBe(false);
|
expect(workflow.hasPath('Node1', 'Node2')).toBe(false);
|
||||||
expect(workflow.hasPath('Node2', 'Node1')).toBe(false);
|
expect(workflow.hasPath('Node2', 'Node1')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return true when source node has pinned data (virtual path)', () => {
|
||||||
|
const nodes: INode[] = [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
name: 'Trigger',
|
||||||
|
type: 'n8n-nodes-base.executeWorkflowTrigger',
|
||||||
|
typeVersion: 1,
|
||||||
|
position: [0, 0],
|
||||||
|
parameters: {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '2',
|
||||||
|
name: 'EditFields',
|
||||||
|
type: 'n8n-nodes-base.set',
|
||||||
|
typeVersion: 1,
|
||||||
|
position: [200, 0],
|
||||||
|
parameters: {},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const connections: IConnections = {
|
||||||
|
Trigger: {
|
||||||
|
main: [[{ node: 'EditFields', type: 'main', index: 0 }]],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const pinData: IPinData = {
|
||||||
|
Trigger: [
|
||||||
|
{
|
||||||
|
json: {
|
||||||
|
name: 'Test item',
|
||||||
|
value: 123,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const workflow = new Workflow({
|
||||||
|
nodes,
|
||||||
|
connections,
|
||||||
|
active: false,
|
||||||
|
nodeTypes,
|
||||||
|
pinData,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Should return true because Trigger has pinned data, creating a virtual path
|
||||||
|
expect(workflow.hasPath('Trigger', 'EditFields')).toBe(true);
|
||||||
|
// Should also work for self-reference with pinned data
|
||||||
|
expect(workflow.hasPath('Trigger', 'Trigger')).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user