fix: workflow incorrectly marked as completed while nodes are still executing#26
Conversation
| # Recursively propagate skip | ||
| self.propagate_skip_from_edge(edge.id) | ||
| self._state_manager.mark_edge_skipped(edge.id) |
There was a problem hiding this comment.
🔴 Skip propagation fails due to incorrect order of operations - edge marked as skipped AFTER propagation
The _propagate_skip_to_node method calls propagate_skip_from_edge(edge.id) before mark_edge_skipped(edge.id), which breaks skip propagation.
Click to expand
Root Cause
In the changed code at lines 84-86, the order of operations was swapped:
for edge in outgoing_edges:
# Recursively propagate skip
self.propagate_skip_from_edge(edge.id) # Called first
self._state_manager.mark_edge_skipped(edge.id) # Called secondHowever, propagate_skip_from_edge at line 53 calls analyze_edge_states(incoming_edges) which checks the state of each incoming edge. Since edges default to NodeState.UNKNOWN (see api/core/workflow/graph/edge.py:15), the edge being processed is still UNKNOWN when propagate_skip_from_edge is called.
Actual vs Expected Behavior
- Actual:
analyze_edge_statesreturnshas_unknown=Truebecause the edge hasn't been marked as SKIPPED yet, causingpropagate_skip_from_edgeto return early at line 56-57 without propagating the skip. - Expected: The edge should be marked as SKIPPED first, so
analyze_edge_statescorrectly identifies all edges as skipped and propagation continues.
Impact
Skip propagation will fail to propagate through the graph correctly. Downstream nodes that should be skipped will not be marked as skipped, potentially causing:
- Nodes executing when they shouldn't
- Workflow completing incorrectly
- The very issue this PR claims to fix (workflow marked as completed while nodes are still executing) may actually be made worse
Recommendation: Restore the original order - call mark_edge_skipped(edge.id) before propagate_skip_from_edge(edge.id):
for edge in outgoing_edges:
self._state_manager.mark_edge_skipped(edge.id)
# Recursively propagate skip
self.propagate_skip_from_edge(edge.id)Was this helpful? React with 👍 or 👎 to provide feedback.
| if edge_states["has_taken"]: | ||
| # Enqueue node | ||
| # Start execution and enqueue node | ||
| print(f"Starting execution for node: {downstream_node_id}") |
There was a problem hiding this comment.
🟡 Debug print statement left in production code
A debug print() statement was left in the production code, which violates the project's coding standards.
Click to expand
Issue
Line 62 contains:
print(f"Starting execution for node: {downstream_node_id}")According to AGENTS.md rule #3 ("Backend Code Must Use Logging Instead of Print Statements"), all output should use the logging module rather than print statements.
Impact
- Debug output will appear in production logs/stdout
- Inconsistent with the rest of the codebase which uses proper logging
- May cause issues in production environments where stdout is not expected
Recommendation: Either remove the debug statement entirely, or replace it with proper logging:
import logging
logger = logging.getLogger(__name__)
# ...
logger.debug(f"Starting execution for node: {downstream_node_id}")Was this helpful? React with 👍 or 👎 to provide feedback.
Benchmark PR from qodo-benchmark#441