From 4f8b70b58637d1c8ce5ad9fb13e41aaafb9c3af0 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Tue, 7 Apr 2026 20:42:25 -0700 Subject: [PATCH] fix(manual): mock payloads nested recursion --- .../lib/workflows/triggers/trigger-utils.ts | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/apps/sim/lib/workflows/triggers/trigger-utils.ts b/apps/sim/lib/workflows/triggers/trigger-utils.ts index f1ee5ce7450..699cbc51756 100644 --- a/apps/sim/lib/workflows/triggers/trigger-utils.ts +++ b/apps/sim/lib/workflows/triggers/trigger-utils.ts @@ -67,7 +67,9 @@ function generateMockValue(type: string, _description?: string, fieldName?: stri } /** - * Recursively processes nested output structures + * Recursively processes nested output structures, expanding JSON-Schema-style + * objects/arrays that define `properties` or `items` instead of returning + * a generic placeholder. */ function processOutputField(key: string, field: unknown, depth = 0, maxDepth = 10): unknown { if (depth > maxDepth) { @@ -80,7 +82,30 @@ function processOutputField(key: string, field: unknown, depth = 0, maxDepth = 1 'type' in field && typeof (field as Record).type === 'string' ) { - const typedField = field as { type: string; description?: string } + const typedField = field as { + type: string + description?: string + properties?: Record + items?: unknown + } + + if ( + (typedField.type === 'object' || typedField.type === 'json') && + typedField.properties && + typeof typedField.properties === 'object' + ) { + const nestedObject: Record = {} + for (const [nestedKey, nestedField] of Object.entries(typedField.properties)) { + nestedObject[nestedKey] = processOutputField(nestedKey, nestedField, depth + 1, maxDepth) + } + return nestedObject + } + + if (typedField.type === 'array' && typedField.items && typeof typedField.items === 'object') { + const itemValue = processOutputField(`${key}_item`, typedField.items, depth + 1, maxDepth) + return [itemValue] + } + return generateMockValue(typedField.type, typedField.description, key) }