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(Mailchimp Trigger Node): Fix webhook recreation #5328

Merged
merged 3 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 6 additions & 2 deletions packages/cli/src/workflows/workflows.services.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { validate as jsonSchemaValidate } from 'jsonschema';
import type { INode, IPinData, JsonObject } from 'n8n-workflow';
import { INode, IPinData, JsonObject, NodeApiError } from 'n8n-workflow';
import { jsonParse, LoggerProxy, Workflow } from 'n8n-workflow';
import type { FindOptionsWhere } from 'typeorm';
import { In } from 'typeorm';
Expand Down Expand Up @@ -336,8 +336,12 @@ export class WorkflowsService {
// Also set it in the returned data
updatedWorkflow.active = false;

let message;
if (error instanceof NodeApiError) message = error.description;
message = message ?? (error as Error).message;

// Now return the original error for UI to display
throw new ResponseHelper.BadRequestError((error as Error).message);
throw new ResponseHelper.BadRequestError(message);
}
}

Expand Down
16 changes: 7 additions & 9 deletions packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,8 @@ export class MailchimpTrigger implements INodeType {
// select them easily
async getLists(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
let lists, response;
try {
response = await mailchimpApiRequest.call(this, '/lists', 'GET');
lists = response.lists;
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
const response = await mailchimpApiRequest.call(this, '/lists', 'GET');
const lists = response.lists;
for (const list of lists) {
const listName = list.name;
const listId = list.id;
Expand Down Expand Up @@ -200,8 +195,11 @@ export class MailchimpTrigger implements INodeType {
try {
await mailchimpApiRequest.call(this, endpoint, 'GET');
} catch (error) {
if (error.statusCode === 404) {
return false;
if (error instanceof NodeApiError && error.cause && 'isAxiosError' in error.cause) {
if (error.cause.statusCode === 404) {
return false;
}
throw error;
}
throw new NodeApiError(this.getNode(), error);
}
Expand Down