Skip to content

Commit c1983de

Browse files
j15zicecrasher321
authored andcommitted
fix(copilot): require workflow id for cancellation
1 parent 5852833 commit c1983de

5 files changed

Lines changed: 22 additions & 13 deletions

File tree

apps/sim/lib/copilot/generated/tool-catalog-v1.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,13 +1629,9 @@ export const CancelWorkflowRun: ToolCatalogEntry = {
16291629
description:
16301630
'Required workflow execution ID returned by run_workflow with async:true or found with query_logs. This identifies a workflow run, not an agent invocation or chat request.',
16311631
},
1632-
workflowId: {
1633-
type: 'string',
1634-
description:
1635-
'Workflow ID that owns the execution. Optional; omit it to target the current workflow. Pass it when cancelling a run from another workflow.',
1636-
},
1632+
workflowId: { type: 'string', description: 'Required workflow ID that owns the execution.' },
16371633
},
1638-
required: ['executionId'],
1634+
required: ['workflowId', 'executionId'],
16391635
},
16401636
requiredPermission: 'write',
16411637
requiresApproval: true,

apps/sim/lib/copilot/generated/tool-schemas-v1.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,11 +1571,10 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
15711571
},
15721572
workflowId: {
15731573
type: 'string',
1574-
description:
1575-
'Workflow ID that owns the execution. Optional; omit it to target the current workflow. Pass it when cancelling a run from another workflow.',
1574+
description: 'Required workflow ID that owns the execution.',
15761575
},
15771576
},
1578-
required: ['executionId'],
1577+
required: ['workflowId', 'executionId'],
15791578
},
15801579
resultSchema: undefined,
15811580
},

apps/sim/lib/copilot/tools/handlers/param-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export interface RunWorkflowParams {
6161
}
6262

6363
export interface CancelWorkflowRunParams {
64-
workflowId?: string
64+
workflowId: string
6565
/** The workflow execution ID returned by run_workflow or query_logs. */
66-
executionId?: string
66+
executionId: string
6767
}
6868

6969
export interface RunWorkflowUntilBlockParams {

apps/sim/lib/copilot/tools/handlers/workflow/mutations.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import { beforeEach, describe, expect, it, vi } from 'vitest'
55
import type { ExecutionContext } from '@/lib/copilot/request/types'
6+
import type { CancelWorkflowRunParams } from '@/lib/copilot/tools/handlers/param-types'
67
import { WorkflowRunAlreadyTerminalError } from '@/lib/execution/workflow-run-already-terminal-error'
78

89
const { mocks } = vi.hoisted(() => ({
@@ -226,12 +227,25 @@ describe('workflow mutation Copilot adapters', () => {
226227
})
227228

228229
it('requires an execution ID before attempting workflow-run cancellation', async () => {
229-
const result = await executeCancelWorkflowRun({ workflowId: 'workflow-1' }, context)
230+
const result = await executeCancelWorkflowRun(
231+
{ workflowId: 'workflow-1' } as CancelWorkflowRunParams,
232+
context
233+
)
230234

231235
expect(result).toEqual({ success: false, error: 'executionId is required' })
232236
expect(mocks.executeWorkflowUseCase).not.toHaveBeenCalled()
233237
})
234238

239+
it('requires a workflow ID even when the execution context contains one', async () => {
240+
const result = await executeCancelWorkflowRun(
241+
{ executionId: 'execution-1' } as CancelWorkflowRunParams,
242+
context
243+
)
244+
245+
expect(result).toEqual({ success: false, error: 'workflowId is required' })
246+
expect(mocks.executeWorkflowUseCase).not.toHaveBeenCalled()
247+
})
248+
235249
it.each([
236250
{
237251
label: 'until',

apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export async function executeCancelWorkflowRun(
289289
context: ExecutionContext
290290
): Promise<ToolCallResult> {
291291
try {
292-
const workflowId = params.workflowId || context.workflowId
292+
const workflowId = params.workflowId
293293
if (!workflowId) {
294294
return { success: false, error: 'workflowId is required' }
295295
}

0 commit comments

Comments
 (0)