Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent NodeApiError rewraping (no-changelog) #9627

Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export async function activeCampaignApiRequest(
return responseData[dataKey] as IDataObject;
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there must be a better way to do this instead of having to repeat this so many times.
perhaps we can try moving this check inside the NodeApiError constructor.

Copy link
Contributor Author

@michael-radency michael-radency Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider this, but what if we actually want to re-wrap error? and if we decide to do that for NodeApiError we probably want same policy for other error types
Despite a lot of files changed this would be less invasive and better for performance, as it's simple check

updated pr to disable errors re-wrapping

throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function acuitySchedulingApiRequest(
);
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Affinity/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function affinityApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function agileCrmApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down Expand Up @@ -168,6 +169,7 @@ export async function agileCrmApiRequestUpdate(
return lastSuccesfulUpdateReturn;
} catch (error) {
if (successfulUpdates.length === 0) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
} else {
throw new NodeApiError(this.getNode(), error as JsonObject, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export async function apiTemplateIoApiRequest(
}
return response;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Automizy/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function automizyApiRequest(
//@ts-ignore
return await this.helpers.request.call(this, options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Autopilot/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function autopilotApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function awsApiRequest(
try {
return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function awsApiRequest(
try {
return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export class AwsSqs implements INodeType {
// loads first 1000 queues from SQS
data = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `?${params.join('&')}`);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}

Expand Down Expand Up @@ -372,6 +373,7 @@ export class AwsSqs implements INodeType {
`${queuePath}?${params.join('&')}`,
);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}

Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export async function awsApiRequest(
}
}

if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject); // no XML parsing needed
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function awsApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject); // no XML parsing needed
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function bannerbearApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nodes-base/nodes/Baserow/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function baserowApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down Expand Up @@ -104,6 +105,7 @@ export async function getJwtToken(
const { token } = (await this.helpers.request(options)) as { token: string };
return token;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function bitbucketApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Bitly/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function bitlyApiRequest(
});
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export async function bitwardenApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down Expand Up @@ -99,6 +100,7 @@ export async function getAccessToken(
const { access_token } = await this.helpers.request(options);
return access_token;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Box/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export async function boxApiRequest(
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, 'boxOAuth2Api', options, oAuth2Options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export async function brandfetchApiRequest(

return response;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Bubble/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export async function bubbleApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Chargebee/Chargebee.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ export class Chargebee implements INodeType {
try {
responseData = await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}

Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/CircleCi/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export async function circleciApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export async function webexApiRequest(
tokenType: 'Bearer',
});
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function citrixADCApiRequest(
try {
return await this.helpers.requestWithAuthentication.call(this, 'citrixAdcApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Clearbit/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function clearbitApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/ClickUp/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export async function clickupApiRequest(
);
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export async function cloudflareApiRequest(
}
return await this.helpers.requestWithAuthentication.call(this, 'cloudflareApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Cockpit/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function cockpitApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Coda/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function codaApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function coinGeckoApiRequest(
//@ts-ignore
return await this.helpers.request.call(this, options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Contentful/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function contentfulApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export async function convertKitApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Copper/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export async function copperApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/DeepL/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export async function deepLApiRequest(

return await this.helpers.requestWithAuthentication.call(this, 'deepLApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Demio/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function demioApiRequest(

return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Dhl/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function dhlApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Discourse/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function discourseApiRequest(
}
return await this.helpers.requestWithAuthentication.call(this, 'discourseApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Disqus/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function disqusApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Drift/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function driftApiRequest(
return await this.helpers.requestOAuth2.call(this, 'driftOAuth2Api', options);
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Dropbox/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function dropboxApiRequest(
return await this.helpers.requestOAuth2.call(this, 'dropboxOAuth2Api', options);
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Egoi/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export async function egoiApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export async function elasticSecurityApiRequest(
error.error.error = `${error.error.error}: ${error.error.message}`;
}

if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function elasticsearchApiRequest(
try {
return await this.helpers.requestWithAuthentication.call(this, 'elasticsearchApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down Expand Up @@ -103,6 +104,7 @@ export async function elasticsearchApiRequestAllItems(

return returnData;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/EmailSend/v2/send.operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
continue;
}
delete error.cert;
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Emelia/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function emeliaApiRequest(
try {
return await this.helpers.request.call(this, options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Loading
Loading