Skip to content

Commit 135be67

Browse files
waleedlatif1claude
andcommitted
fix(executor): strengthen format detection per PR review
- Add UUID validation on executionId to eliminate false-positive detection when user Response block data coincidentally contains success + executionId - Scope childWorkflowId/childWorkflowName to standard format only so user payload fields don't leak into child workflow metadata - Add test coverage for both edge cases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a8504f7 commit 135be67

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

apps/sim/tools/workflow/executor.test.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ describe('workflowExecutorTool', () => {
256256
it.concurrent('should parse standard format response', async () => {
257257
const body = {
258258
success: true,
259-
executionId: 'exec-123',
259+
executionId: '550e8400-e29b-41d4-a716-446655440000',
260260
output: { result: 'hello' },
261261
metadata: { duration: 500 },
262262
}
@@ -272,7 +272,7 @@ describe('workflowExecutorTool', () => {
272272
it.concurrent('should parse standard format failure', async () => {
273273
const body = {
274274
success: false,
275-
executionId: 'exec-123',
275+
executionId: '550e8400-e29b-41d4-a716-446655440000',
276276
output: {},
277277
error: 'Something went wrong',
278278
}
@@ -336,6 +336,35 @@ describe('workflowExecutorTool', () => {
336336
expect(result.output).toEqual({ results: [], error: 'No results found' })
337337
expect(result.error).toBe('No results found')
338338
})
339+
340+
it.concurrent(
341+
'should not misidentify user data with success + non-UUID executionId as standard format',
342+
async () => {
343+
const body = { success: true, executionId: 'my-exec-run', data: [1, 2, 3] }
344+
345+
const result = await transformResponse(mockResponse(body))
346+
347+
expect(result.success).toBe(true)
348+
expect(result.output).toEqual({
349+
success: true,
350+
executionId: 'my-exec-run',
351+
data: [1, 2, 3],
352+
})
353+
}
354+
)
355+
356+
it.concurrent(
357+
'should not leak user payload fields into childWorkflowId/childWorkflowName',
358+
async () => {
359+
const body = { workflowId: 'user-wf-id', workflowName: 'User WF', data: 'test' }
360+
361+
const result = await transformResponse(mockResponse(body))
362+
363+
expect(result.childWorkflowId).toBe('')
364+
expect(result.childWorkflowName).toBe('')
365+
expect(result.output).toEqual(body)
366+
}
367+
)
339368
})
340369

341370
describe('tool metadata', () => {

apps/sim/tools/workflow/executor.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { ToolConfig } from '@/tools/types'
22
import type { WorkflowExecutorParams, WorkflowExecutorResponse } from '@/tools/workflow/types'
33

4+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
5+
46
/**
57
* Tool for executing workflows as blocks within other workflows.
68
* This tool is used by the WorkflowBlockHandler to provide the execution capability.
@@ -57,18 +59,20 @@ export const workflowExecutorTool: ToolConfig<
5759
// The execute endpoint has two response shapes:
5860
// 1. Standard: { success, executionId, output, error, metadata }
5961
// 2. Response block: arbitrary user-defined data (no wrapper)
60-
// Detect standard format by checking for executionId (always present) + success boolean.
62+
// Detect standard format via executionId (always a UUID from uuidv4()) + success boolean.
6163
const isStandardFormat =
62-
typeof data?.success === 'boolean' && typeof data?.executionId === 'string'
64+
typeof data?.success === 'boolean' &&
65+
typeof data?.executionId === 'string' &&
66+
UUID_RE.test(data.executionId)
6367

6468
const outputData = isStandardFormat ? (data.output ?? {}) : data
6569
const success = isStandardFormat ? data.success : response.ok
6670

6771
return {
6872
success,
6973
duration: isStandardFormat ? (data?.metadata?.duration ?? 0) : 0,
70-
childWorkflowId: data?.workflowId ?? '',
71-
childWorkflowName: data?.workflowName ?? '',
74+
childWorkflowId: isStandardFormat ? (data?.workflowId ?? '') : '',
75+
childWorkflowName: isStandardFormat ? (data?.workflowName ?? '') : '',
7276
output: outputData,
7377
result: outputData,
7478
error: data?.error,

0 commit comments

Comments
 (0)