Skip to content

Commit a88ab8f

Browse files
committed
clean up
1 parent cd3533e commit a88ab8f

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

apps/sim/executor/execution/block-executor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,6 @@ export class BlockExecutor {
249249
blockLog.input = this.sanitizeInputsForLog(input)
250250
blockLog.output = filterOutputForLog(block.metadata?.id || '', errorOutput, { block })
251251

252-
// Extract childTraceSpans for nested workflow execution errors
253-
// Store separately to keep output clean for display while preserving for trace processing
254252
if (errorOutput.childTraceSpans && Array.isArray(errorOutput.childTraceSpans)) {
255253
blockLog.childTraceSpans = errorOutput.childTraceSpans
256254
}

apps/sim/lib/logs/execution/trace-spans/trace-spans.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,28 @@ function flattenWorkflowChildren(spans: TraceSpan[]): TraceSpan[] {
5454
return
5555
}
5656

57-
// Recursively process children - spans are already clean from buildTraceSpans
58-
const processedSpan: TraceSpan = {
59-
...span,
60-
children: Array.isArray(span.children) ? flattenWorkflowChildren(span.children) : undefined,
57+
const processedSpan: TraceSpan = { ...span }
58+
59+
const directChildren = Array.isArray(span.children) ? span.children : []
60+
const outputChildren =
61+
span.output &&
62+
typeof span.output === 'object' &&
63+
Array.isArray((span.output as { childTraceSpans?: TraceSpan[] }).childTraceSpans)
64+
? ((span.output as { childTraceSpans?: TraceSpan[] }).childTraceSpans as TraceSpan[])
65+
: []
66+
67+
const allChildren = [...directChildren, ...outputChildren]
68+
if (allChildren.length > 0) {
69+
processedSpan.children = flattenWorkflowChildren(allChildren)
6170
}
71+
72+
if (outputChildren.length > 0 && processedSpan.output) {
73+
const { childTraceSpans: _, ...cleanOutput } = processedSpan.output as {
74+
childTraceSpans?: TraceSpan[]
75+
} & Record<string, unknown>
76+
processedSpan.output = cleanOutput
77+
}
78+
6279
flattened.push(processedSpan)
6380
})
6481

@@ -325,23 +342,17 @@ export function buildTraceSpans(result: ExecutionResult): {
325342
}
326343
}
327344

328-
// Handle child workflow trace spans - check both log.childTraceSpans (preferred)
329-
// and log.output.childTraceSpans (backward compatibility)
330345
if (isWorkflowBlockType(log.blockType)) {
331-
const childTraceSpansFromLog = (log as { childTraceSpans?: TraceSpan[] }).childTraceSpans
332-
const childTraceSpansFromOutput = log.output?.childTraceSpans
333-
334-
const childTraceSpans = Array.isArray(childTraceSpansFromLog)
335-
? childTraceSpansFromLog
336-
: Array.isArray(childTraceSpansFromOutput)
337-
? (childTraceSpansFromOutput as TraceSpan[])
346+
const childTraceSpans = Array.isArray(log.childTraceSpans)
347+
? log.childTraceSpans
348+
: Array.isArray(log.output?.childTraceSpans)
349+
? (log.output.childTraceSpans as TraceSpan[])
338350
: null
339351

340352
if (childTraceSpans) {
341353
const flattenedChildren = flattenWorkflowChildren(childTraceSpans)
342354
span.children = flattenedChildren
343355

344-
// Clean childTraceSpans from output if present
345356
if (span.output && typeof span.output === 'object' && 'childTraceSpans' in span.output) {
346357
const { childTraceSpans: _, ...cleanOutput } = span.output as {
347358
childTraceSpans?: TraceSpan[]

0 commit comments

Comments
 (0)