Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions apps/sim/lib/copilot/tools/server/table/user-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,23 +960,40 @@ describe('userTableServerTool workflow scope', () => {
expect(mockAddWorkflowGroup).not.toHaveBeenCalled()
})

it('does not pass a legacy deployment mode into workflow group creation', async () => {
it.each([
{
operation: 'add_workflow_group',
args: {
tableId: 'tbl_1',
workflowId: 'workflow-1',
outputs: [{ blockId: 'block-1', path: 'content' }],
deploymentMode: 'live',
},
},
{
operation: 'update_workflow_group',
args: {
tableId: 'tbl_1',
groupId: 'group-1',
deploymentMode: 'live',
},
},
])('rejects a legacy live deployment mode for $operation', async ({ operation, args }) => {
const result = await userTableServerTool.execute(
{
operation: 'add_workflow_group',
args: {
tableId: 'tbl_1',
workflowId: 'workflow-1',
outputs: [{ blockId: 'block-1', path: 'content' }],
deploymentMode: 'live',
},
operation,
args,
},
buildToolContext()
)

expect(result.success).toBe(true)
expect(mockAddWorkflowGroup).toHaveBeenCalledTimes(1)
expect(mockAddWorkflowGroup.mock.calls[0][0].group).not.toHaveProperty('deploymentMode')
expect(result).toEqual({
success: false,
message:
'deploymentMode "live" is not supported; table workflow groups only run the latest active deployment. Deploy the workflow, then retry without deploymentMode.',
})
expect(mockResolveWorkflowContext).not.toHaveBeenCalled()
expect(mockAddWorkflowGroup).not.toHaveBeenCalled()
})

it('conceals unknown application failures from tool output', async () => {
Expand Down
14 changes: 14 additions & 0 deletions apps/sim/lib/copilot/tools/server/table/user-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,20 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
const workspaceId = context.workspaceId
const assertNotAborted = () =>
assertServerToolNotAborted(context, 'Request aborted before table mutation could be applied.')

// A stale Mothership may still send the removed selector. Never report success
// after silently changing its requested semantics from draft to deployed.
if (
(operation === 'add_workflow_group' || operation === 'update_workflow_group') &&
args.deploymentMode === 'live'
) {
return {
success: false,
message:
'deploymentMode "live" is not supported; table workflow groups only run the latest active deployment. Deploy the workflow, then retry without deploymentMode.',
}
}

try {
switch (operation) {
case 'create': {
Expand Down
Loading