fix: Workflow activation should not crash if one of the credential is invalid (#4671)

fix: workflow activation should not crash if one of the credential is invalid

fixes https://sentry.io/organizations/n8nio/issues/3755260584
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2022-11-21 15:51:23 +01:00 committed by GitHub
parent 30e5d3d04c
commit c0e13c2a8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;