Skip to content

Commit 1bbad84

Browse files
icecrasher321claude
andcommitted
fix(condition): stop shipping all block outputs in every evaluation
ConditionBlockHandler forwarded collectBlockData's full blockData — every block output accumulated so far in the run — to function_execute on each condition evaluation. The resolver already inlines every <block.field> reference into the expression before the handler runs, so that payload was never read; it only inflated the request body. Inside a wide subflow one flat blockStates map holds every branch's outputs, so a 91-branch parallel pushed the body past the 10MB cap and failed the gate with "Request body size limit exceeded" even though the expression was just a boolean compare. Per-value large-value offload does not catch this: its threshold is 8MB for a single value, while this is an aggregate of many medium ones. Mirrors FunctionBlockHandler, which moved to blockData: {} in #4560 and left the condition handler on the old path. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent f09f6d2 commit 1bbad84

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

apps/sim/executor/handlers/condition/condition-handler.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ describe('ConditionBlockHandler', () => {
173173
timeout: 5000,
174174
envVars: mockContext.environmentVariables,
175175
workflowVariables: mockContext.workflowVariables,
176-
blockData: { 'source-block-1': { value: 10, text: 'hello' } },
176+
blockData: {},
177177
blockNameMapping: { sourceblock: 'source-block-1' },
178178
_context: {
179179
workflowId: 'test-workflow-id',
@@ -184,6 +184,24 @@ describe('ConditionBlockHandler', () => {
184184
)
185185
})
186186

187+
it('should never forward collected block outputs in the request body', async () => {
188+
mockCollectBlockData.mockReturnValueOnce({
189+
blockData: { 'huge-block': { payload: 'x'.repeat(1024) } },
190+
blockNameMapping: { hugeblock: 'huge-block' },
191+
})
192+
mockExecuteTool.mockResolvedValueOnce({ success: true, output: { result: true } })
193+
194+
const conditions = [
195+
{ id: 'cond1', title: 'if', value: 'true' },
196+
{ id: 'else1', title: 'else', value: '' },
197+
]
198+
199+
await handler.execute(mockContext, mockBlock, { conditions: JSON.stringify(conditions) })
200+
201+
const [, toolParams] = mockExecuteTool.mock.calls[0]
202+
expect(toolParams.blockData).toEqual({})
203+
})
204+
187205
it('should select the else path if other conditions fail', async () => {
188206
mockExecuteTool.mockResolvedValueOnce({ success: true, output: { result: false } })
189207

apps/sim/executor/handlers/condition/condition-handler.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ const CONDITION_TIMEOUT_MS = 5000
2121
/**
2222
* Evaluates a single condition expression.
2323
* Variable resolution is handled consistently with the function block via the function_execute tool.
24+
*
25+
* `blockData` is deliberately empty: the resolver already inlines every `<block.field>` reference
26+
* into the expression before this runs, so shipping the run's accumulated block outputs would only
27+
* inflate the request body. Sending them blew the 10MB body cap on wide subflows, where a single
28+
* flat `blockStates` map holds every branch's outputs.
29+
*
2430
* Returns true if condition is met, false otherwise.
2531
*/
2632
async function evaluateConditionExpression(
@@ -35,7 +41,7 @@ async function evaluateConditionExpression(
3541
const contextSetup = `const context = ${JSON.stringify(evalContext)};`
3642
const code = `${contextSetup}\nreturn Boolean(${conditionExpression})`
3743

38-
const { blockData, blockNameMapping, blockOutputSchemas } = collectBlockData(ctx, currentNodeId)
44+
const { blockNameMapping, blockOutputSchemas } = collectBlockData(ctx, currentNodeId)
3945

4046
const result = await executeTool(
4147
'function_execute',
@@ -44,7 +50,7 @@ async function evaluateConditionExpression(
4450
timeout: CONDITION_TIMEOUT_MS,
4551
envVars: normalizeStringRecord(ctx.environmentVariables),
4652
workflowVariables: normalizeWorkflowVariables(ctx.workflowVariables),
47-
blockData,
53+
blockData: {},
4854
blockNameMapping,
4955
blockOutputSchemas,
5056
_context: {

0 commit comments

Comments
 (0)