Skip to content

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Dec 11, 2025

Summary

Fix condition block evaluation if no outgoing edge

Type of Change

  • Bug fix

Testing

Manual

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 Dec 11, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Dec 11, 2025 7:18am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 11, 2025

Greptile Overview

Greptile Summary

Fixed condition block evaluation to handle the edge case where a condition evaluates to true but has no outgoing connection/edge configured.

Key Changes:

  • Reordered evaluation logic to check if condition is met before looking for connections
  • Added graceful handling when a true condition has no outgoing edge - logs informational message and returns null values
  • Prevents execution from attempting to follow non-existent paths
  • Branch ends gracefully instead of silently failing or throwing errors

Impact:
This fix allows workflows to handle incomplete condition configurations more gracefully, where developers may have defined conditions but not yet connected them to subsequent blocks. The workflow execution continues correctly without errors.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a targeted bug fix that improves robustness by handling an edge case gracefully. The logic change is straightforward - checking condition evaluation before connection lookup - and includes proper logging for debugging. The fix prevents potential runtime issues when conditions have no outgoing edges, which is a valid workflow configuration scenario.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/executor/handlers/condition/condition-handler.ts 5/5 Fixed condition evaluation to handle cases where a condition is true but has no outgoing edge, allowing the branch to end gracefully instead of failing

Sequence Diagram

sequenceDiagram
    participant Executor
    participant ConditionHandler
    participant Resolver
    participant Logger

    Executor->>ConditionHandler: execute(ctx, block, inputs)
    ConditionHandler->>ConditionHandler: parseConditions(inputs.conditions)
    ConditionHandler->>ConditionHandler: buildEvaluationContext(ctx, block.id, sourceBlockId)
    ConditionHandler->>ConditionHandler: evaluateConditions(conditions, outgoingConnections, evalContext, ctx, block)
    
    loop For each condition
        alt Condition is "else"
            ConditionHandler->>ConditionHandler: findConnectionForCondition(outgoingConnections, condition.id)
            alt Connection exists
                ConditionHandler-->>Executor: Return selectedConnection & selectedCondition
            end
        else Regular condition
            ConditionHandler->>Resolver: resolveVariableReferences(conditionValueString, block)
            Resolver-->>ConditionHandler: resolvedVars
            ConditionHandler->>Resolver: resolveBlockReferences(resolvedVars, ctx, block)
            Resolver-->>ConditionHandler: resolvedRefs
            ConditionHandler->>Resolver: resolveEnvVariables(resolvedRefs)
            Resolver-->>ConditionHandler: resolvedConditionValue
            ConditionHandler->>ConditionHandler: evaluateConditionExpression(ctx, conditionValueString, block, resolver, evalContext)
            
            alt Condition is TRUE
                ConditionHandler->>ConditionHandler: findConnectionForCondition(outgoingConnections, condition.id)
                alt Connection exists
                    ConditionHandler-->>Executor: Return selectedConnection & selectedCondition
                else No outgoing edge (FIX)
                    ConditionHandler->>Logger: log info "Condition is true but has no outgoing edge"
                    ConditionHandler-->>Executor: Return null connection & null condition
                end
            end
        end
    end
    
    alt No condition matched
        ConditionHandler->>Logger: log info "No condition matched - branch ending"
        ConditionHandler-->>Executor: Return null connection & null condition
    end
    
    Executor->>Executor: Process return value (conditionResult: false, selectedPath: null)
Loading

Copy link
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.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@Sg312 Sg312 merged commit c550e45 into staging Dec 11, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/condition-block branch December 11, 2025 08:27
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