From 0031cf9486509c5f593bfe94cccc401785d34e4e 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: Mon, 21 Nov 2022 15:26:55 +0100 Subject: [PATCH] fix: workflow activation should not crash if one of the credential is invalid fixes https://sentry.io/organizations/n8nio/issues/3755260584 --- .../cli/src/workflows/workflows.services.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/workflows/workflows.services.ts b/packages/cli/src/workflows/workflows.services.ts index 15add92f45980..42199c43612a8 100644 --- a/packages/cli/src/workflows/workflows.services.ts +++ b/packages/cli/src/workflows/workflows.services.ts @@ -1,6 +1,7 @@ import { validate as jsonSchemaValidate } from 'jsonschema'; import { INode, IPinData, JsonObject, jsonParse, LoggerProxy, Workflow } from 'n8n-workflow'; import { FindManyOptions, FindOneOptions, In, ObjectLiteral } from 'typeorm'; +import pick from 'lodash.pick'; import * as ActiveWorkflowRunner from '@/ActiveWorkflowRunner'; import * as Db from '@/Db'; import { InternalHooksManager } from '@/InternalHooksManager'; @@ -254,9 +255,18 @@ export class WorkflowsService { await validateEntity(workflow); } - const { hash, ...rest } = workflow; - - await Db.collections.Workflow.update(workflowId, rest); + await Db.collections.Workflow.update( + workflowId, + pick(workflow, [ + 'name', + 'active', + 'nodes', + 'connections', + 'settings', + 'staticData', + 'pinData', + ]), + ); if (tags && !config.getEnv('workflowTagsDisabled')) { const tablePrefix = config.getEnv('database.tablePrefix'); @@ -306,8 +316,7 @@ export class WorkflowsService { ); } catch (error) { // If workflow could not be activated set it again to inactive - workflow.active = false; - await Db.collections.Workflow.update(workflowId, workflow); + await Db.collections.Workflow.update(workflowId, { active: false }); // Also set it in the returned data updatedWorkflow.active = false;