From 0e9a5a2ab2cde251cf106b149bdd4c3142e52b40 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Wed, 31 Jan 2024 12:12:18 +0000 Subject: [PATCH] fix: Properly iterate over credentials with expressions (#8502) --- 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 6079fea634..d70f9f0372 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 38412b1d8a..baa9aec208 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 1d49a68cce..7dcc8da243 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;