@@ -23,28 +23,7 @@ function resolveFromWebhookPayload(container: any, property: string): any {
2323 return undefined
2424}
2525
26- // Global fallback: scan any block state's webhook payload for the property (e.g., when referencing
27- // a GitHub field from a non-trigger block). This allows <github1.sender> to resolve even if the
28- // referenced block doesn't carry the webhook metadata on its own output.
29- function resolveFromAnyWebhookPayload ( context : ExecutionContext | undefined , property : string ) : any {
30- try {
31- if ( ! context ) return undefined
32- for ( const state of context . blockStates . values ( ) ) {
33- const payload = ( state as any ) ?. output ?. webhook ?. data ?. payload
34- if ( payload && typeof payload === 'object' && Object . prototype . hasOwnProperty . call ( payload , property ) ) {
35- return payload [ property ]
36- }
37- }
38- } catch ( _ ) {
39- // ignore
40- }
41- return undefined
42- }
43-
44-
45-
4626/**
47- *
4827 * Helper function to resolve property access
4928 */
5029function resolvePropertyAccess ( obj : any , property : string ) : any {
@@ -70,44 +49,13 @@ export class InputResolver {
7049 // Create maps for efficient lookups
7150 this . blockById = new Map ( workflow . blocks . map ( ( block ) => [ block . id , block ] ) )
7251
73- // Initialize the normalized name map with trigger-preference for duplicate names
74- this . blockByNormalizedName = new Map ( )
75- const isTriggerDef = ( b : SerializedBlock | undefined ) =>
76- ! ! b && ( b . metadata ?. category === 'triggers' || b . config ?. params ?. triggerMode === true )
77-
78- for ( const block of workflow . blocks ) {
79- const key = block . metadata ?. name ? this . normalizeBlockName ( block . metadata . name ) : block . id
80- const existing = this . blockByNormalizedName . get ( key )
81- if ( ! existing ) {
82- this . blockByNormalizedName . set ( key , block )
83- } else {
84- // Prefer trigger blocks when duplicate names exist
85- if ( ! isTriggerDef ( existing ) && isTriggerDef ( block ) ) {
86- this . blockByNormalizedName . set ( key , block )
87- }
88- }
89- }
90-
91- // Add provider-index aliases for trigger blocks to ensure intuitive references like <github1>
92- // regardless of the block's display name (e.g., "GitHub Webhook 1"). Only applies to triggers.
93- const providerToBlocks : Record < string , SerializedBlock [ ] > = { }
94- for ( const block of workflow . blocks ) {
95- if ( ! isTriggerDef ( block ) ) continue
96- const typeId = ( block . metadata ?. id || '' ) . toLowerCase ( )
97- // Detect GitHub triggers by id containing 'github' (covers 'github_webhook')
98- if ( typeId . includes ( 'github' ) ) {
99- providerToBlocks . github = providerToBlocks . github || [ ]
100- providerToBlocks . github . push ( block )
101- }
102- }
103-
104- // Register aliases like 'github1', 'github2', ...
105- if ( providerToBlocks . github && providerToBlocks . github . length > 0 ) {
106- providerToBlocks . github . forEach ( ( b , idx ) => {
107- const alias = `github${ idx + 1 } `
108- this . blockByNormalizedName . set ( alias , b )
109- } )
110- }
52+ // Initialize the normalized name map
53+ this . blockByNormalizedName = new Map (
54+ workflow . blocks . map ( ( block ) => [
55+ block . metadata ?. name ? this . normalizeBlockName ( block . metadata . name ) : block . id ,
56+ block ,
57+ ] )
58+ )
11159
11260 // Add special handling for the starter block - allow referencing it as "start"
11361 const starterBlock = workflow . blocks . find ( ( block ) => block . metadata ?. id === 'starter' )
@@ -625,13 +573,11 @@ export class InputResolver {
625573
626574 replacementValue = arrayValue [ index ]
627575 } else {
628- // Regular property access with webhook metadata fallback; then global webhook payload fallback
576+ // Regular property access with webhook metadata fallback only
629577 let nextValue = resolvePropertyAccess ( replacementValue , part )
630578 if ( nextValue === undefined ) {
579+ // Fallback to webhook metadata payload if present
631580 nextValue = resolveFromWebhookPayload ( replacementValue , part )
632- if ( nextValue === undefined ) {
633- nextValue = resolveFromAnyWebhookPayload ( context , part )
634- }
635581 }
636582 replacementValue = nextValue
637583 }
@@ -835,13 +781,11 @@ export class InputResolver {
835781
836782 replacementValue = arrayValue [ index ]
837783 } else {
838- // Regular property access with webhook metadata fallback; then global webhook payload fallback
784+ // Regular property access with webhook metadata fallback only
839785 let nextValue = resolvePropertyAccess ( replacementValue , part )
840786 if ( nextValue === undefined ) {
787+ // Fallback to webhook metadata payload if present
841788 nextValue = resolveFromWebhookPayload ( replacementValue , part )
842- if ( nextValue === undefined ) {
843- nextValue = resolveFromAnyWebhookPayload ( context , part )
844- }
845789 }
846790 replacementValue = nextValue
847791 }
0 commit comments