@@ -28,6 +28,24 @@ export class PathConstructor {
2828 const block = workflow . blocks . find ( ( b ) => b . id === triggerBlockId )
2929
3030 if ( block ) {
31+ if ( ! block . enabled ) {
32+ logger . error ( 'Provided triggerBlockId is disabled, finding alternative' , {
33+ triggerBlockId,
34+ blockEnabled : block . enabled ,
35+ } )
36+ // Try to find an alternative enabled trigger instead of failing
37+ const alternativeTrigger = this . findExplicitTrigger ( workflow )
38+ if ( alternativeTrigger ) {
39+ logger . info ( 'Using alternative enabled trigger' , {
40+ disabledTriggerId : triggerBlockId ,
41+ alternativeTriggerId : alternativeTrigger ,
42+ } )
43+ return alternativeTrigger
44+ }
45+ throw new Error (
46+ `Trigger block ${ triggerBlockId } is disabled and no alternative enabled trigger found`
47+ )
48+ }
3149 return triggerBlockId
3250 }
3351
@@ -95,8 +113,13 @@ export class PathConstructor {
95113
96114 private buildAdjacencyMap ( workflow : SerializedWorkflow ) : Map < string , string [ ] > {
97115 const adjacency = new Map < string , string [ ] > ( )
116+ const enabledBlocks = new Set ( workflow . blocks . filter ( ( b ) => b . enabled ) . map ( ( b ) => b . id ) )
98117
99118 for ( const connection of workflow . connections ) {
119+ if ( ! enabledBlocks . has ( connection . source ) || ! enabledBlocks . has ( connection . target ) ) {
120+ continue
121+ }
122+
100123 const neighbors = adjacency . get ( connection . source ) ?? [ ]
101124 neighbors . push ( connection . target )
102125 adjacency . set ( connection . source , neighbors )
0 commit comments