From 3507ad651f9961009231c7805c91248bee09c7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Wed, 1 Feb 2023 18:33:17 +0100 Subject: [PATCH 1/3] try to return more info on workflow update errors --- packages/cli/src/workflows/workflows.services.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/workflows/workflows.services.ts b/packages/cli/src/workflows/workflows.services.ts index 7bc0b38f9360a..f275db44d3fbe 100644 --- a/packages/cli/src/workflows/workflows.services.ts +++ b/packages/cli/src/workflows/workflows.services.ts @@ -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'; @@ -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); } } From 038a124b3bef5496f5d4cf43552172d79198b098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Wed, 1 Feb 2023 18:35:04 +0100 Subject: [PATCH 2/3] fix (Mailchimp Trigger Node): Handle deleted webhooks correctly because of the double wrapping of errors, `error.statusCode` was not the response http code. --- .../nodes/Mailchimp/MailchimpTrigger.node.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts b/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts index 8496778bbd809..524edc6def38a 100644 --- a/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts @@ -165,13 +165,8 @@ export class MailchimpTrigger implements INodeType { // select them easily async getLists(this: ILoadOptionsFunctions): Promise { 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; @@ -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); } From 35a4c62ed7f9f597698ead006d7293e9fdf97432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Wed, 1 Feb 2023 18:51:49 +0100 Subject: [PATCH 3/3] fix linting error --- packages/cli/src/workflows/workflows.services.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/workflows/workflows.services.ts b/packages/cli/src/workflows/workflows.services.ts index f275db44d3fbe..902896ac127fc 100644 --- a/packages/cli/src/workflows/workflows.services.ts +++ b/packages/cli/src/workflows/workflows.services.ts @@ -1,6 +1,6 @@ import { validate as jsonSchemaValidate } from 'jsonschema'; -import { INode, IPinData, JsonObject, NodeApiError } from 'n8n-workflow'; -import { jsonParse, LoggerProxy, Workflow } from 'n8n-workflow'; +import type { INode, IPinData, JsonObject } from 'n8n-workflow'; +import { NodeApiError, jsonParse, LoggerProxy, Workflow } from 'n8n-workflow'; import type { FindOptionsWhere } from 'typeorm'; import { In } from 'typeorm'; import pick from 'lodash.pick';