fix: Resolve expressions in credentials following paired item (#8250)

## Summary
Fixes the issue that pairedItem information was not available in
expressions that got used in credentials


## Related tickets and issues

[PAY-1207](https://linear.app/n8n/issue/PAY-1207/paireditem-expressions-not-working-correctly-in-credentials)


## Review / Merge checklist
- [x] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up
ticket created.
- [ ] Tests included.
> A bug is not considered fixed, unless a test is added to prevent it
from happening again.
   > A feature is not complete without tests.

---------

Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
Jan Oberhauser
2024-01-08 10:48:20 +01:00
committed by GitHub
parent 008fd5a917
commit ccb2b076f8
7 changed files with 56 additions and 39 deletions

View File

@@ -1221,44 +1221,6 @@ export class HttpRequestV3 implements INodeType {
let nodeCredentialType: string | undefined;
let genericCredentialType: string | undefined;
if (authentication === 'genericCredentialType') {
genericCredentialType = this.getNodeParameter('genericAuthType', 0) as string;
if (genericCredentialType === 'httpBasicAuth') {
try {
httpBasicAuth = await this.getCredentials('httpBasicAuth');
} catch {}
} else if (genericCredentialType === 'httpDigestAuth') {
try {
httpDigestAuth = await this.getCredentials('httpDigestAuth');
} catch {}
} else if (genericCredentialType === 'httpHeaderAuth') {
try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
} catch {}
} else if (genericCredentialType === 'httpQueryAuth') {
try {
httpQueryAuth = await this.getCredentials('httpQueryAuth');
} catch {}
} else if (genericCredentialType === 'httpCustomAuth') {
try {
httpCustomAuth = await this.getCredentials('httpCustomAuth');
} catch {}
} else if (genericCredentialType === 'oAuth1Api') {
try {
oAuth1Api = await this.getCredentials('oAuth1Api');
} catch {}
} else if (genericCredentialType === 'oAuth2Api') {
try {
oAuth2Api = await this.getCredentials('oAuth2Api');
} catch {}
}
} else if (authentication === 'predefinedCredentialType') {
try {
nodeCredentialType = this.getNodeParameter('nodeCredentialType', 0) as string;
} catch {}
}
type RequestOptions = OptionsWithUri & { useStream?: boolean };
let requestOptions: RequestOptions = {
uri: '',
@@ -1293,6 +1255,44 @@ export class HttpRequestV3 implements INodeType {
};
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
if (authentication === 'genericCredentialType') {
genericCredentialType = this.getNodeParameter('genericAuthType', 0) as string;
if (genericCredentialType === 'httpBasicAuth') {
try {
httpBasicAuth = await this.getCredentials('httpBasicAuth', itemIndex);
} catch {}
} else if (genericCredentialType === 'httpDigestAuth') {
try {
httpDigestAuth = await this.getCredentials('httpDigestAuth', itemIndex);
} catch {}
} else if (genericCredentialType === 'httpHeaderAuth') {
try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth', itemIndex);
} catch {}
} else if (genericCredentialType === 'httpQueryAuth') {
try {
httpQueryAuth = await this.getCredentials('httpQueryAuth', itemIndex);
} catch {}
} else if (genericCredentialType === 'httpCustomAuth') {
try {
httpCustomAuth = await this.getCredentials('httpCustomAuth', itemIndex);
} catch {}
} else if (genericCredentialType === 'oAuth1Api') {
try {
oAuth1Api = await this.getCredentials('oAuth1Api', itemIndex);
} catch {}
} else if (genericCredentialType === 'oAuth2Api') {
try {
oAuth2Api = await this.getCredentials('oAuth2Api', itemIndex);
} catch {}
}
} else if (authentication === 'predefinedCredentialType') {
try {
nodeCredentialType = this.getNodeParameter('nodeCredentialType', 0) as string;
} catch {}
}
const requestMethod = this.getNodeParameter('method', itemIndex) as string;
const sendQuery = this.getNodeParameter('sendQuery', itemIndex, false) as boolean;