From f40ae501b4dca8f00db41d8fc07b496ad06cf10f Mon Sep 17 00:00:00 2001 From: Mike Arvela Date: Wed, 14 Sep 2022 18:40:45 +0300 Subject: [PATCH] fix(public-api): Fix error updating workflow with property not defined in the schema (#4089) * fix(cli): catch errors on updating workflow * :zap: Don\'t allow additionalProperties in the workflow schema Co-authored-by: ricardo --- .../v1/handlers/workflows/spec/schemas/workflow.yml | 1 + .../PublicApi/v1/handlers/workflows/workflows.handler.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/PublicApi/v1/handlers/workflows/spec/schemas/workflow.yml b/packages/cli/src/PublicApi/v1/handlers/workflows/spec/schemas/workflow.yml index bac8120af8..f04070f85b 100644 --- a/packages/cli/src/PublicApi/v1/handlers/workflows/spec/schemas/workflow.yml +++ b/packages/cli/src/PublicApi/v1/handlers/workflows/spec/schemas/workflow.yml @@ -1,4 +1,5 @@ type: object +additionalProperties: false required: - name - nodes diff --git a/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.handler.ts b/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.handler.ts index 0a41e1d478..74aa2bd0ab 100644 --- a/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.handler.ts +++ b/packages/cli/src/PublicApi/v1/handlers/workflows/workflows.handler.ts @@ -198,7 +198,13 @@ export = { await workflowRunner.remove(id.toString()); } - await updateWorkflow(sharedWorkflow.workflowId, updateData); + try { + await updateWorkflow(sharedWorkflow.workflowId, updateData); + } catch (error) { + if (error instanceof Error) { + return res.status(400).json({ message: error.message }); + } + } if (sharedWorkflow.workflow.active) { try {