Skip to content

Fix typing error#15699

Merged
martmull merged 1 commit intomainfrom
fix-workflow-execution-error
Nov 7, 2025
Merged

Fix typing error#15699
martmull merged 1 commit intomainfrom
fix-workflow-execution-error

Conversation

@martmull
Copy link
Copy Markdown
Contributor

@martmull martmull commented Nov 7, 2025

Fix typing error

@martmull martmull enabled auto-merge (squash) November 7, 2025 11:51
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR fixes a TypeScript typing error in the getNextStepIdsToExecute method by properly handling the case where executedStepResult.result could be undefined.

Changes:

  • Added undefined to the type assertion for iteratorStepResult (line 198-200)
  • Changed property access from iteratorStepResult.hasProcessedAllItems to iteratorStepResult?.hasProcessedAllItems using optional chaining (line 202)

Context:
The WorkflowActionOutput type defines result as optional (result?: object), meaning it can be undefined. When this result is cast to WorkflowIteratorResult for iterator steps, the code was not accounting for the possibility of undefined, which would cause a runtime error when trying to access hasProcessedAllItems on an undefined value.

Impact:
This fix prevents potential runtime errors when processing workflow iterator steps that have undefined results, improving type safety and runtime stability.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a straightforward type safety fix that adds proper null handling. It addresses a real issue where result can be undefined according to the WorkflowActionOutput type definition. The fix follows TypeScript best practices by using optional chaining and union types. No logic changes were made, only defensive type handling was added.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-server/src/modules/workflow/workflow-executor/workspace-services/workflow-executor.workspace-service.ts 5/5 Fixed type safety issue by adding undefined to type assertion and using optional chaining for hasProcessedAllItems access

Sequence Diagram

sequenceDiagram
    participant Executor as WorkflowExecutor
    participant Method as getNextStepIdsToExecute
    participant Guard as isWorkflowIteratorAction
    participant Result as executedStepResult
    
    Executor->>Method: Call with executedStep & executedStepResult
    Method->>Guard: Check if step is iterator
    Guard-->>Method: Returns true/false
    
    alt Is Iterator Step
        Method->>Result: Cast result as WorkflowIteratorResult | undefined
        Method->>Result: Check iteratorStepResult?.hasProcessedAllItems
        alt Not all items processed
            Method-->>Executor: Return initialLoopStepIds
        else All items processed
            Method-->>Executor: Return executedStep.nextStepIds
        end
    else Not Iterator Step
        Method-->>Executor: Return executedStep.nextStepIds
    end
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 7, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:19287

This environment will automatically shut down when the PR is closed or after 5 hours.

Copy link
Copy Markdown
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

Left a comment otherwise LGTM!

@martmull martmull merged commit 196a75e into main Nov 7, 2025
50 checks passed
@martmull martmull deleted the fix-workflow-execution-error branch November 7, 2025 12:29
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