Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Nested spans handoff in error case for workflow in workflow block.

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 24, 2026 10:13am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 24, 2026

Greptile Summary

This PR fixes the nested trace spans handoff in child workflow error cases by introducing a proper ChildWorkflowError class.

Key changes:

  • Created ChildWorkflowError class to encapsulate child workflow failures with structured properties (childTraceSpans, childWorkflowName, executionResult)
  • Updated workflow-handler.ts to throw ChildWorkflowError instead of dynamically attaching properties to generic Error objects
  • Modified block-executor.ts to properly detect and extract trace spans from ChildWorkflowError instances using type guard
  • Fixed critical bug where blockLog.output was not being set in error cases, which prevented trace spans from being logged
  • Reordered operations in handleBlockError to set block output before updating block log, ensuring trace spans are captured

The fix ensures that when nested workflows fail, their execution traces are properly propagated up through parent workflows for debugging and observability.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-structured and address a specific bug in trace span propagation. The new ChildWorkflowError class provides better type safety compared to the previous approach of dynamically adding properties. The fix ensures blockLog.output is properly set in error cases, which was missing before. All changes are backward compatible and tests verify the error handling behavior.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/executor/errors/child-workflow-error.ts New custom error class created to properly encapsulate child workflow failure information with trace spans
apps/sim/executor/execution/block-executor.ts Updated error handling to properly extract childTraceSpans from ChildWorkflowError and include errorOutput in blockLog.output
apps/sim/executor/handlers/workflow/workflow-handler.ts Replaced ad-hoc error property manipulation with proper ChildWorkflowError class for better type safety and trace span propagation

Sequence Diagram

sequenceDiagram
    participant PE as Parent Executor
    participant WH as WorkflowHandler
    participant CE as Child Executor
    participant BE as BlockExecutor
    
    PE->>WH: execute(workflow block)
    WH->>CE: execute child workflow
    
    alt Child workflow succeeds
        CE-->>WH: ExecutionResult with logs
        WH->>WH: captureChildWorkflowLogs()
        WH-->>PE: Return success with childTraceSpans
    else Child workflow fails
        CE-->>WH: throw error with executionResult
        WH->>WH: Extract childTraceSpans from error.executionResult
        WH->>WH: Create ChildWorkflowError
        WH-->>BE: throw ChildWorkflowError
        BE->>BE: Check ChildWorkflowError.isChildWorkflowError()
        BE->>BE: Extract childTraceSpans to errorOutput
        BE->>BE: Set blockLog.output with errorOutput
        BE->>BE: Set block state with errorOutput
        alt Has error port
            BE-->>PE: Return errorOutput with childTraceSpans
        else No error port
            BE-->>PE: throw error with childTraceSpans preserved
        end
    end
Loading

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321 icecrasher321 merged commit 211a7ac into staging Jan 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants