From 4bec37831b44a03a0df5d5b592d006508bb482d2 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Wed, 31 Jan 2024 08:29:26 +0000 Subject: [PATCH] fix: Properly iterate over credentials with expressions --- packages/core/src/NodeExecuteFunctions.ts | 5 ++++- .../nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts | 3 ++- packages/workflow/src/Interfaces.ts | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 6079fea6347a2..d70f9f03722aa 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -1714,6 +1714,7 @@ export async function requestWithAuthentication( node: INode, additionalData: IWorkflowExecuteAdditionalData, additionalCredentialOptions?: IAdditionalCredentialOptions, + itemIndex?: number, ) { let credentialsDecrypted: ICredentialDataDecryptedObject | undefined; @@ -1738,7 +1739,7 @@ export async function requestWithAuthentication( if (additionalCredentialOptions?.credentialsDecrypted) { credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data; } else { - credentialsDecrypted = await this.getCredentials(credentialsType); + credentialsDecrypted = await this.getCredentials(credentialsType, itemIndex); } if (credentialsDecrypted === undefined) { @@ -3000,6 +3001,7 @@ const getRequestHelperFunctions = ( credentialsType, requestOptions, additionalCredentialOptions, + itemIndex, ): Promise { return await requestWithAuthentication.call( this, @@ -3009,6 +3011,7 @@ const getRequestHelperFunctions = ( node, additionalData, additionalCredentialOptions, + itemIndex, ); }, diff --git a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts index 38412b1d8a92f..baa9aec208ff1 100644 --- a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts @@ -1274,7 +1274,7 @@ export class HttpRequestV3 implements INodeType { oAuth2Api = await this.getCredentials('oAuth2Api', itemIndex); } } else if (authentication === 'predefinedCredentialType') { - nodeCredentialType = this.getNodeParameter('nodeCredentialType', 0) as string; + nodeCredentialType = this.getNodeParameter('nodeCredentialType', itemIndex) as string; } const requestMethod = this.getNodeParameter('method', itemIndex) as string; @@ -1714,6 +1714,7 @@ export class HttpRequestV3 implements INodeType { nodeCredentialType, requestOptions, additionalOAuth2Options && { oauth2: additionalOAuth2Options }, + itemIndex, ); requestWithAuthentication.catch(() => {}); requestPromises.push(requestWithAuthentication); diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index 1d49a68cce208..7dcc8da2432fa 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -721,6 +721,7 @@ export interface RequestHelperFunctions { credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, additionalCredentialOptions?: IAdditionalCredentialOptions, + itemIndex?: number, ): Promise; httpRequest(requestOptions: IHttpRequestOptions): Promise;