Skip to content

Commit 2d3d820

Browse files
committed
fix(copilot): reject live table workflow requests
1 parent b19553e commit 2d3d820

2 files changed

Lines changed: 42 additions & 11 deletions

File tree

apps/sim/lib/copilot/tools/server/table/user-table.test.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -960,23 +960,40 @@ describe('userTableServerTool workflow scope', () => {
960960
expect(mockAddWorkflowGroup).not.toHaveBeenCalled()
961961
})
962962

963-
it('does not pass a legacy deployment mode into workflow group creation', async () => {
963+
it.each([
964+
{
965+
operation: 'add_workflow_group',
966+
args: {
967+
tableId: 'tbl_1',
968+
workflowId: 'workflow-1',
969+
outputs: [{ blockId: 'block-1', path: 'content' }],
970+
deploymentMode: 'live',
971+
},
972+
},
973+
{
974+
operation: 'update_workflow_group',
975+
args: {
976+
tableId: 'tbl_1',
977+
groupId: 'group-1',
978+
deploymentMode: 'live',
979+
},
980+
},
981+
])('rejects a legacy live deployment mode for $operation', async ({ operation, args }) => {
964982
const result = await userTableServerTool.execute(
965983
{
966-
operation: 'add_workflow_group',
967-
args: {
968-
tableId: 'tbl_1',
969-
workflowId: 'workflow-1',
970-
outputs: [{ blockId: 'block-1', path: 'content' }],
971-
deploymentMode: 'live',
972-
},
984+
operation,
985+
args,
973986
},
974987
buildToolContext()
975988
)
976989

977-
expect(result.success).toBe(true)
978-
expect(mockAddWorkflowGroup).toHaveBeenCalledTimes(1)
979-
expect(mockAddWorkflowGroup.mock.calls[0][0].group).not.toHaveProperty('deploymentMode')
990+
expect(result).toEqual({
991+
success: false,
992+
message:
993+
'deploymentMode "live" is not supported; table workflow groups only run the latest active deployment. Deploy the workflow, then retry without deploymentMode.',
994+
})
995+
expect(mockResolveWorkflowContext).not.toHaveBeenCalled()
996+
expect(mockAddWorkflowGroup).not.toHaveBeenCalled()
980997
})
981998

982999
it('conceals unknown application failures from tool output', async () => {

apps/sim/lib/copilot/tools/server/table/user-table.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
202202
const workspaceId = context.workspaceId
203203
const assertNotAborted = () =>
204204
assertServerToolNotAborted(context, 'Request aborted before table mutation could be applied.')
205+
206+
// A stale Mothership may still send the removed selector. Never report success
207+
// after silently changing its requested semantics from draft to deployed.
208+
if (
209+
(operation === 'add_workflow_group' || operation === 'update_workflow_group') &&
210+
args.deploymentMode === 'live'
211+
) {
212+
return {
213+
success: false,
214+
message:
215+
'deploymentMode "live" is not supported; table workflow groups only run the latest active deployment. Deploy the workflow, then retry without deploymentMode.',
216+
}
217+
}
218+
205219
try {
206220
switch (operation) {
207221
case 'create': {

0 commit comments

Comments
 (0)