From 703e2c1873b7e0033b52a98de691caa14f36c777 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 22 Jul 2024 17:20:30 +0200 Subject: [PATCH] Prevent renaming row actions --- .../server/src/sdk/app/automations/crud.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/server/src/sdk/app/automations/crud.ts b/packages/server/src/sdk/app/automations/crud.ts index f3dd3e7a3c..875c7d4a9d 100644 --- a/packages/server/src/sdk/app/automations/crud.ts +++ b/packages/server/src/sdk/app/automations/crud.ts @@ -1,4 +1,9 @@ -import { Automation, Webhook, WebhookActionType } from "@budibase/types" +import { + Automation, + AutomationTriggerStepId, + Webhook, + WebhookActionType, +} from "@budibase/types" import { generateAutomationID, getAutomationParams } from "../../../db/utils" import { deleteEntityMetadata } from "../../../utilities" import { MetadataTypes } from "../../../constants" @@ -117,7 +122,6 @@ export async function create(automation: Automation) { export async function update(automation: Automation) { automation = { ...automation } - if (!automation._id || !automation._rev) { throw new HTTPError("_id or _rev fields missing", 400) } @@ -281,4 +285,14 @@ function guardInvalidUpdatesAndThrow( } }) } + + if (isRowAction(automation) && automation.name !== oldAutomation.name) { + throw new Error("Row actions cannot be renamed") + } +} + +function isRowAction(automation: Automation) { + const result = + automation.definition.trigger.stepId === AutomationTriggerStepId.ROW_ACTION + return result }