Skip to content

Commit 3294a9c

Browse files
committed
fix(workflow-tests): never read a mock error past the cap as an empty output
An error longer than the 10,000-character cap failed the error branch and fell through to the output branch, which still read it as an empty output. The output branch is now strict, so such a reply is refused instead.
1 parent f5f7b37 commit 3294a9c

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎apps/sim/lib/workflow-tests/protocol.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ describe('testReplyArgsSchema', () => {
2525
output: null,
2626
})
2727
})
28+
29+
it('never reads an error past the cap as an empty output', () => {
30+
const reply = { runId: 'r', callId: 'c', error: 'x'.repeat(10_001) }
31+
expect(testReplyArgsSchema.safeParse(reply).success).toBe(false)
32+
})
2833
})

‎apps/sim/lib/workflow-tests/protocol.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export const testStartArgsSchema = z.object({
4747
*/
4848
export const testReplyArgsSchema = z.union([
4949
z.object({ runId: z.string().min(1), callId: z.string().min(1), error: z.string().max(10_000) }),
50-
z.object({ runId: z.string().min(1), callId: z.string().min(1), output: z.unknown() }),
50+
// Strict, so a reply carrying an `error` (one past the cap included) is never read as an output.
51+
z
52+
.object({ runId: z.string().min(1), callId: z.string().min(1), output: z.unknown() })
53+
.strict(),
5154
])
5255

5356
export const testNextArgsSchema = z.object({ runId: z.string().min(1) })

0 commit comments

Comments
 (0)