Skip to content

Commit 79857e1

Browse files
committed
Fix bugs
1 parent 07dfedd commit 79857e1

3 files changed

Lines changed: 34 additions & 11 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,11 +1661,16 @@ export function useWorkflowExecution() {
16611661
},
16621662

16631663
onExecutionError: (data) => {
1664-
if (data.error?.includes('Block not found in workflow')) {
1664+
const isWorkflowModified =
1665+
data.error?.includes('Block not found in workflow') ||
1666+
data.error?.includes('Upstream dependency not executed')
1667+
1668+
if (isWorkflowModified) {
16651669
clearLastExecutionSnapshot(workflowId)
16661670
addNotification({
1667-
level: 'info',
1668-
message: 'Workflow was modified. Run the workflow again to refresh.',
1671+
level: 'error',
1672+
message:
1673+
'Workflow was modified. Run the workflow again to enable running from block.',
16691674
workflowId,
16701675
})
16711676
} else {

apps/sim/executor/utils/run-from-block.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,24 @@ describe('validateRunFromBlock', () => {
331331
expect(result.error).toContain('Upstream dependency not executed')
332332
})
333333

334+
it('rejects blocks with unexecuted transitive upstream dependencies', () => {
335+
// A → X → B → C, where X is new (not executed)
336+
// Running from C should fail because X in upstream chain wasn't executed
337+
const dag = createDAG([
338+
createNode('A', [{ target: 'X' }]),
339+
createNode('X', [{ target: 'B' }]),
340+
createNode('B', [{ target: 'C' }]),
341+
createNode('C'),
342+
])
343+
const executedBlocks = new Set(['A', 'B', 'C']) // X was not executed (new block)
344+
345+
const result = validateRunFromBlock('C', dag, executedBlocks)
346+
347+
expect(result.valid).toBe(false)
348+
expect(result.error).toContain('Upstream dependency not executed')
349+
expect(result.error).toContain('X')
350+
})
351+
334352
it('allows blocks with no dependencies even if not previously executed', () => {
335353
// A and B are independent (no edges)
336354
const dag = createDAG([createNode('A'), createNode('B')])

apps/sim/executor/utils/run-from-block.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,15 @@ export function validateRunFromBlock(
169169
if (node.metadata.isSentinel) {
170170
return { valid: false, error: 'Cannot run from sentinel node' }
171171
}
172+
}
172173

173-
if (node.incomingEdges.size > 0) {
174-
for (const sourceId of node.incomingEdges.keys()) {
175-
if (!executedBlocks.has(sourceId)) {
176-
return {
177-
valid: false,
178-
error: `Upstream dependency not executed: ${sourceId}`,
179-
}
180-
}
174+
// Check that ALL upstream blocks were executed (transitive check)
175+
const { upstreamSet } = computeExecutionSets(dag, blockId)
176+
for (const upstreamId of upstreamSet) {
177+
if (!executedBlocks.has(upstreamId)) {
178+
return {
179+
valid: false,
180+
error: `Upstream dependency not executed: ${upstreamId}`,
181181
}
182182
}
183183
}

0 commit comments

Comments
 (0)