From 6bd953799cd95a48b1ff865a7736c2941183b2f9 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Tue, 11 Aug 2026 21:26:35 -0700 Subject: [PATCH] fix(tables): prevent legacy group auto-run dispatch --- apps/sim/lib/table/application/groups.test.ts | 44 +++++++++++++++++++ apps/sim/lib/table/application/groups.ts | 4 +- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/apps/sim/lib/table/application/groups.test.ts b/apps/sim/lib/table/application/groups.test.ts index c9a62cf929f..b119b6a8c3f 100644 --- a/apps/sim/lib/table/application/groups.test.ts +++ b/apps/sim/lib/table/application/groups.test.ts @@ -378,6 +378,28 @@ describe('workflow and enrichment Table application commands', () => { ) }) + it('does not start auto-run when the generic update saves a legacy enabled group', async () => { + await updateTableGroupUseCase.execute({ + principal, + input: { + tableId: table.id, + workspaceId: table.workspaceId, + groupId: group.id, + autoRun: true, + }, + }) + + expect(mocks.updateGroup).toHaveBeenCalledWith( + expect.objectContaining({ + autoRun: true, + suppressAutoRunDispatch: true, + }), + 'request-1' + ) + expect(mocks.runDetached).not.toHaveBeenCalled() + expect(mocks.runWorkflowColumn).not.toHaveBeenCalled() + }) + it('rejects an invalid output before constructing or mutating the group', async () => { await expect( createWorkflowTableGroup.execute({ @@ -513,6 +535,28 @@ describe('workflow and enrichment Table application commands', () => { expect(mocks.signal).not.toHaveBeenCalled() }) + it('does not start auto-run when the workflow update saves a legacy enabled group', async () => { + await updateWorkflowTableGroup.execute({ + principal, + input: { + tableId: table.id, + workspaceId: table.workspaceId, + groupId: group.id, + autoRun: true, + }, + }) + + expect(mocks.updateGroup).toHaveBeenCalledWith( + expect.objectContaining({ + autoRun: true, + suppressAutoRunDispatch: true, + }), + 'request-1' + ) + expect(mocks.runDetached).not.toHaveBeenCalled() + expect(mocks.runWorkflowColumn).not.toHaveBeenCalled() + }) + it('passes authorized output type and ordering to the add-output mutation', async () => { await addWorkflowTableGroupOutput.execute({ principal, diff --git a/apps/sim/lib/table/application/groups.ts b/apps/sim/lib/table/application/groups.ts index ab3906ea365..b6f01039557 100644 --- a/apps/sim/lib/table/application/groups.ts +++ b/apps/sim/lib/table/application/groups.ts @@ -635,7 +635,7 @@ export const updateTableGroupUseCase = defineAuthorizedTableUseCase({ changed: JSON.stringify(context.table.schema) !== JSON.stringify(table.schema) || JSON.stringify(context.table.metadata) !== JSON.stringify(table.metadata), - startAutoRun: previousGroup?.autoRun !== true && input.autoRun === true, + startAutoRun: previousGroup?.autoRun === false && input.autoRun === true, actorUserId, } }, @@ -824,7 +824,7 @@ export const updateWorkflowTableGroup = defineAuthorizedTableUseCase({ changed: JSON.stringify(context.table.schema) !== JSON.stringify(table.schema) || JSON.stringify(context.table.metadata) !== JSON.stringify(table.metadata), - startAutoRun: previousGroup.autoRun !== true && input.autoRun === true, + startAutoRun: previousGroup.autoRun === false && input.autoRun === true, actorUserId, } },