Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 121 additions & 1 deletion packages/core/src/execution-engine/__tests__/routing-node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const getExecuteSingleFunctions = (
describe('RoutingNode', () => {
const nodeTypes = NodeTypes();
const additionalData = mock<IWorkflowExecuteAdditionalData>({
executionId: 'test-exec-123',
webhookWaitingBaseUrl: 'http://localhost:5678/webhook-waiting',
formWaitingBaseUrl: 'http://localhost:5678/form-waiting',
});
Expand Down Expand Up @@ -753,6 +754,7 @@ describe('RoutingNode', () => {
mode,
connectionInputData,
runExecutionData,
nodeType,
});
const routingNode = new RoutingNode(executeFunctions, nodeType);

Expand Down Expand Up @@ -790,7 +792,7 @@ describe('RoutingNode', () => {
nodeType: {
properties?: INodeProperties[];
credentials?: INodeCredentialDescription[];
requestDefaults?: IHttpRequestOptions;
requestDefaults?: DeclarativeRestApiSettings.HttpRequestOptions;
requestOperations?: IN8nRequestOperations;
};
node: {
Expand Down Expand Up @@ -2057,6 +2059,124 @@ describe('RoutingNode', () => {
],
],
},
{
description: 'single parameter, routing.request.url resolves $execution.id',
input: {
node: {
parameters: {
resource: 'executions',
},
},
nodeType: {
requestDefaults: {
baseURL: 'http://127.0.0.1:5678',
},
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'string',
routing: {
request: {
method: 'GET',
url: '=/{{$value}}/{{ $execution.id }}',
},
},
default: '',
},
],
},
},
output: [
[
{
json: {
headers: {},
statusCode: 200,
requestOptions: {
url: '/executions/test-exec-123',
method: 'GET',
headers: {},
qs: {},
body: {},
baseURL: 'http://127.0.0.1:5678',
returnFullResponse: true,
timeout: 300000,
},
},
},
],
],
},
{
description:
'options parameter with routing.request.url on selected option resolves $execution.id via $parameter',
input: {
node: {
parameters: {
operation: 'get',
executionId: '={{ $execution.id }}',
},
},
nodeType: {
requestDefaults: {
baseURL: 'http://127.0.0.1:5678',
},
properties: [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
default: 'get',
options: [
{
name: 'Get',
value: 'get',
routing: {
request: {
method: 'GET',
url: '=/executions/{{ $parameter.executionId }}',
},
},
},
],
},
{
displayName: 'Execution ID',
name: 'executionId',
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['get'],
},
},
},
],
},
},
output: [
[
{
json: {
headers: {},
statusCode: 200,
requestOptions: {
url: '/executions/test-exec-123',
method: 'GET',
headers: {},
qs: {},
body: {},
baseURL: 'http://127.0.0.1:5678',
returnFullResponse: true,
timeout: 300000,
},
},
},
],
],
},
];

const baseNode: INode = {
Expand Down
26 changes: 19 additions & 7 deletions packages/core/src/execution-engine/routing-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import type {
import url from 'node:url';

import { type ExecuteContext, ExecuteSingleContext } from './node-execution-context';
import { getAdditionalKeys } from './node-execution-context/utils/get-additional-keys';

export class RoutingNode {
constructor(
Expand Down Expand Up @@ -132,6 +133,8 @@ export class RoutingNode {
};
}

const additionalKeys = getAdditionalKeys(additionalData, mode, runExecutionData);

if (nodeType.description.requestDefaults) {
for (const key of Object.keys(nodeType.description.requestDefaults)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -142,7 +145,7 @@ export class RoutingNode {
itemIndex,
runIndex,
executeData,
{ $credentials: credentials, $version: node.typeVersion },
{ ...additionalKeys, $credentials: credentials, $version: node.typeVersion },
false,
) as string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -158,7 +161,7 @@ export class RoutingNode {
itemIndex,
runIndex,
executeData,
{ $credentials: credentials, $version: node.typeVersion },
{ ...additionalKeys, $credentials: credentials, $version: node.typeVersion },
false,
) as string | NodeParameterValue;

Expand All @@ -168,7 +171,12 @@ export class RoutingNode {
itemIndex,
runIndex,
'',
{ $credentials: credentials, $value: value, $version: node.typeVersion },
{
...additionalKeys,
$credentials: credentials,
$value: value,
$version: node.typeVersion,
},
);

this.mergeOptions(itemContext[itemIndex].requestData, tempOptions);
Expand Down Expand Up @@ -850,7 +858,7 @@ export class RoutingNode {
itemIndex,
runIndex,
executeSingleFunctions.getExecuteData(),
additionalKeys,
{ ...additionalKeys, $value: parameterValue },
true,
) as string;

Expand Down Expand Up @@ -993,7 +1001,7 @@ export class RoutingNode {
itemIndex,
runIndex,
`${basePath}${nodeProperties.name}`,
{ $value: optionValue, $version: node.typeVersion },
{ ...additionalKeys, $value: optionValue, $version: node.typeVersion },
);

this.mergeOptions(returnData, tempOptions);
Expand All @@ -1017,7 +1025,7 @@ export class RoutingNode {
itemIndex,
runIndex,
`${basePath}${nodeProperties.name}`,
{ $version: node.typeVersion },
{ ...additionalKeys, $version: node.typeVersion },
);

this.mergeOptions(returnData, tempOptions);
Expand Down Expand Up @@ -1061,7 +1069,11 @@ export class RoutingNode {
itemIndex,
runIndex,
nodeProperties.typeOptions?.multipleValues ? `${loopBasePath}[${i}]` : loopBasePath,
{ ...(additionalKeys || {}), $index: i, $parent: value[i] },
{
...(additionalKeys || {}),
$index: i,
$parent: value[i],
},
);

this.mergeOptions(returnData, tempOptions);
Expand Down
Loading