Skip to content

Commit 9ee5dfe

Browse files
improvement(workflow): hide raw json childworkflow span (#3019)
1 parent 9cba8ee commit 9ee5dfe

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
EDGE,
1313
isSentinelBlockType,
1414
isTriggerBehavior,
15+
isWorkflowBlockType,
1516
} from '@/executor/constants'
1617
import type { DAGNode } from '@/executor/dag/builder'
1718
import { ChildWorkflowError } from '@/executor/errors/child-workflow-error'
@@ -154,8 +155,8 @@ export class BlockExecutor {
154155
this.state.setBlockOutput(node.id, normalizedOutput, duration)
155156

156157
if (!isSentinel) {
157-
const filteredOutput = this.filterOutputForLog(block, normalizedOutput)
158-
this.callOnBlockComplete(ctx, node, block, resolvedInputs, filteredOutput, duration)
158+
const displayOutput = this.filterOutputForDisplay(block, normalizedOutput)
159+
this.callOnBlockComplete(ctx, node, block, resolvedInputs, displayOutput, duration)
159160
}
160161

161162
return normalizedOutput
@@ -245,7 +246,8 @@ export class BlockExecutor {
245246
)
246247

247248
if (!isSentinel) {
248-
this.callOnBlockComplete(ctx, node, block, input, errorOutput, duration)
249+
const displayOutput = this.filterOutputForDisplay(block, errorOutput)
250+
this.callOnBlockComplete(ctx, node, block, input, displayOutput, duration)
249251
}
250252

251253
const hasErrorPort = this.hasErrorPortEdge(node)
@@ -337,7 +339,9 @@ export class BlockExecutor {
337339
block: SerializedBlock,
338340
output: NormalizedBlockOutput
339341
): NormalizedBlockOutput {
340-
if (block.metadata?.id === BlockType.HUMAN_IN_THE_LOOP) {
342+
const blockType = block.metadata?.id
343+
344+
if (blockType === BlockType.HUMAN_IN_THE_LOOP) {
341345
const filtered: NormalizedBlockOutput = {}
342346
for (const [key, value] of Object.entries(output)) {
343347
if (key.startsWith('_')) continue
@@ -360,6 +364,22 @@ export class BlockExecutor {
360364
return output
361365
}
362366

367+
private filterOutputForDisplay(
368+
block: SerializedBlock,
369+
output: NormalizedBlockOutput
370+
): NormalizedBlockOutput {
371+
const filtered = this.filterOutputForLog(block, output)
372+
373+
if (isWorkflowBlockType(block.metadata?.id)) {
374+
const { childTraceSpans: _, ...displayOutput } = filtered as {
375+
childTraceSpans?: unknown
376+
} & Record<string, unknown>
377+
return displayOutput
378+
}
379+
380+
return filtered
381+
}
382+
363383
private callOnBlockStart(ctx: ExecutionContext, node: DAGNode, block: SerializedBlock): void {
364384
const blockId = node.id
365385
const blockName = block.metadata?.name ?? blockId

0 commit comments

Comments
 (0)