fix(executor): handle Response block format in workflow executor tool#3532
fix(executor): handle Response block format in workflow executor tool#3532waleedlatif1 wants to merge 2 commits intostagingfrom
Conversation
When a child workflow has a Response block, the execute endpoint returns
the block's data directly without the standard {success, executionId, output}
wrapper. The transformResponse was defaulting success to false, causing
"Tool execution failed" errors even when the workflow completed successfully.
Detect the response format by checking for executionId + success boolean,
and fall back to response.ok for Response block responses.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
PR SummaryMedium Risk Overview The parser now detects the standard wrapper via Written by Cursor Bugbot for commit a8504f7. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR fixes a bug in the workflow executor tool's The fix introduces a two-format detection heuristic in Key changes:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[transformResponse called] --> B[await response.json to get data]
B --> C{success is boolean AND executionId is string?}
C -- Yes --> D[isStandardFormat = true]
C -- No --> E[isStandardFormat = false]
D --> F[outputData = data.output or empty obj]
D --> G[success = data.success]
D --> H[duration = data.metadata.duration or 0]
E --> I[outputData = data]
E --> J[success = response.ok]
E --> K[duration = 0]
F --> L[Return result object]
I --> L
G --> L
J --> L
H --> L
K --> L
L --> M[success, duration, childWorkflowId, childWorkflowName, output, result, error]
Last reviewed commit: a8504f7 |
apps/sim/tools/workflow/executor.ts
Outdated
| const isStandardFormat = | ||
| typeof data?.success === 'boolean' && typeof data?.executionId === 'string' |
There was a problem hiding this comment.
False-positive format detection for user data with executionId field
The heuristic typeof data?.success === 'boolean' && typeof data?.executionId === 'string' will misidentify a user-defined Response block payload that happens to include both a boolean success field and a string executionId field (e.g., a workflow that re-wraps or forwards another workflow's output, or a workflow querying the executions API and returning raw rows).
When misidentified as standard format, data.output ?? {} is returned as outputData — but user payloads normally have no output key, so the caller silently receives an empty object {} instead of the actual response data, without any error.
Consider adding a third discriminator that is effectively impossible to appear in arbitrary user data. For example, requiring data?.metadata !== undefined (always present in the standard envelope) alongside executionId:
| const isStandardFormat = | |
| typeof data?.success === 'boolean' && typeof data?.executionId === 'string' | |
| const isStandardFormat = | |
| typeof data?.success === 'boolean' && | |
| typeof data?.executionId === 'string' && | |
| data?.metadata !== undefined |
Or document this known limitation clearly in a code comment so future maintainers understand the trade-off.
apps/sim/tools/workflow/executor.ts
Outdated
| childWorkflowId: data?.workflowId ?? '', | ||
| childWorkflowName: data?.workflowName ?? '', |
There was a problem hiding this comment.
childWorkflowId/childWorkflowName read from arbitrary user payload
In the Response-block format path, data is the raw user-defined payload (e.g., { issues: [], total: 0 }). Reading data?.workflowId and data?.workflowName from this payload will always fall back to '' for typical user data — but if a user's workflow intentionally returns an object with a workflowId or workflowName field (e.g., a workflow that queries workflow metadata), those user-defined values will be incorrectly surfaced as child-workflow metadata in the result.
Consider defaulting these fields to '' unconditionally for the Response-block path:
| childWorkflowId: data?.workflowId ?? '', | |
| childWorkflowName: data?.workflowName ?? '', | |
| childWorkflowId: isStandardFormat ? (data?.workflowId ?? '') : '', | |
| childWorkflowName: isStandardFormat ? (data?.workflowName ?? '') : '', |
- 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 <[email protected]>
Summary
{"issues": []}) without the standard{success, executionId, output}wrappertransformResponsein the workflow executor tool was defaultingsuccesstofalseviadata?.success ?? false, causing every agent tool call to a Response-block workflow to report "Tool execution failed" — even when the workflow completed successfullyexecutionId(string) +success(boolean), and falls back toresponse.okfor Response block responsesTest plan
successfield, empty data, array data, anderrorfield preservationbunx vitest run tools/workflow/executor.test.ts)