Skip to content

Commit f07a81a

Browse files
Adam GoughAdam Gough
authored andcommitted
test
1 parent 15025d0 commit f07a81a

3 files changed

Lines changed: 17 additions & 89 deletions

File tree

apps/sim/executor/handlers/trigger/trigger-handler.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ export class TriggerBlockHandler implements BlockHandler {
4545
// Generic handling for webhook triggers - extract provider-specific data
4646

4747

48-
// Check if this is a webhook execution with nested structure
49-
if (starterOutput.webhook?.data || starterOutput.github) {
48+
// Check if this is a webhook execution
49+
if (starterOutput.webhook?.data) {
5050
const webhookData = starterOutput.webhook?.data || {}
51-
const provider = webhookData.provider || (starterOutput.github ? 'github' : undefined)
51+
const provider = webhookData.provider
5252

5353
logger.debug(`Processing webhook trigger for block ${block.id}`, {
5454
provider,
@@ -57,26 +57,11 @@ export class TriggerBlockHandler implements BlockHandler {
5757

5858
// Provider-specific early return for GitHub: expose raw payload at root
5959
if (provider === 'github') {
60-
// Prefer raw payload from webhook metadata; otherwise fall back to nested provider object;
61-
// finally, as a last resort, use the starter output itself.
62-
const payloadSource =
63-
(webhookData && webhookData.payload) || starterOutput.github || starterOutput || {}
64-
65-
const result: any = {
66-
// Root is the raw GitHub payload
60+
const payloadSource = webhookData.payload || {}
61+
return {
6762
...payloadSource,
68-
// Keep metadata available
6963
webhook: starterOutput.webhook,
7064
}
71-
72-
// Ensure no nested provider alias remains
73-
if (result.github) {
74-
try {
75-
delete result.github
76-
} catch {}
77-
}
78-
79-
return result
8065
}
8166

8267
// Extract the flattened properties that should be at root level (non-GitHub)

apps/sim/executor/index.ts

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -869,25 +869,8 @@ export class Executor {
869869
// This ensures files are captured in trace spans and execution logs
870870
this.createStartedBlockWithFilesLog(initBlock, starterOutput, context)
871871
} else {
872-
// API/Trigger workflow: spread the raw data directly (no wrapping)
873-
// Special case for GitHub webhooks: if input contains a nested 'github' object,
874-
// promote it to root so fields can be accessed at <github1.field>.
875-
const provider = this.workflowInput?.webhook?.data?.provider
876-
let starterOutput: any
877-
878-
if (provider === 'github') {
879-
const flattened =
880-
this.workflowInput && typeof this.workflowInput.github === 'object'
881-
? this.workflowInput.github
882-
: this.workflowInput
883-
884-
starterOutput = {
885-
...flattened,
886-
webhook: this.workflowInput?.webhook,
887-
}
888-
} else {
889-
starterOutput = { ...this.workflowInput }
890-
}
872+
// API/Trigger workflow: spread the raw data directly (no wrapping or aliasing)
873+
const starterOutput: any = { ...this.workflowInput }
891874

892875
context.blockStates.set(initBlock.id, {
893876
output: starterOutput,
@@ -1614,24 +1597,7 @@ export class Executor {
16141597
? rawOutput
16151598
: { result: rawOutput }
16161599

1617-
// Normalize trigger outputs: for GitHub triggers, promote nested github payload to root
1618-
try {
1619-
const isTriggerBlock = block.metadata?.category === 'triggers' || block.config?.params?.triggerMode === true
1620-
const provider = (output as any)?.webhook?.data?.provider
1621-
if (isTriggerBlock && provider === 'github') {
1622-
const candidate = (output as any).github || (output as any)?.webhook?.data?.payload || output
1623-
const normalized: Record<string, any> = {
1624-
...(typeof candidate === 'object' && candidate !== null ? candidate : {}),
1625-
webhook: (output as any)?.webhook,
1626-
}
1627-
if (normalized.github) {
1628-
delete normalized.github
1629-
}
1630-
output = normalized as NormalizedBlockOutput
1631-
}
1632-
} catch {
1633-
// Non-fatal: keep original output
1634-
}
1600+
// Remove provider-specific normalization. Expect payload fields at root already.
16351601

16361602
// Update the context with the execution result
16371603
// Use virtual block ID for parallel executions

apps/sim/executor/resolver/resolver.ts

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,7 @@ import type { SerializedBlock, SerializedWorkflow } from '@/serializer/types'
88

99
const logger = createLogger('InputResolver')
1010

11-
// Minimal fallback: if a property isn't found at the current level,
12-
// attempt to resolve it from a nested `github` alias commonly present in webhook payloads.
13-
function resolveWithGithubAlias(container: any, property: string): any {
14-
if (!container || typeof container !== 'object') return undefined
15-
const nested = container.github
16-
if (nested && typeof nested === 'object' && Object.prototype.hasOwnProperty.call(nested, property)) {
17-
return nested[property]
18-
}
19-
return undefined
20-
}
11+
// Removed provider alias fallbacks (e.g., nested `github`).
2112

2213
// Fallback into webhook metadata payload if present: { webhook: { data: { payload: {...} } } }
2314
function resolveFromWebhookPayload(container: any, property: string): any {
@@ -547,10 +538,7 @@ export class InputResolver {
547538
// This enables direct access to <start.input> and <start.conversationId>
548539
let replacementValue: any = blockState.output
549540

550-
// Merge nested github object onto root to make <block.repository> resolve transparently
551-
if (replacementValue && typeof replacementValue === 'object' && replacementValue.github && typeof replacementValue.github === 'object') {
552-
replacementValue = { ...replacementValue.github, ...replacementValue }
553-
}
541+
// Do not merge nested provider aliases. Expect payload fields at the root.
554542

555543
for (const part of pathParts) {
556544
if (!replacementValue || typeof replacementValue !== 'object') {
@@ -585,15 +573,11 @@ export class InputResolver {
585573

586574
replacementValue = arrayValue[index]
587575
} else {
588-
// Regular property access with a GitHub alias fallback
576+
// Regular property access with webhook metadata fallback only
589577
let nextValue = resolvePropertyAccess(replacementValue, part)
590578
if (nextValue === undefined) {
591-
// Fallback to nested github alias if present
592-
nextValue = resolveWithGithubAlias(replacementValue, part)
593-
if (nextValue === undefined) {
594-
// Fallback to webhook metadata payload if present
595-
nextValue = resolveFromWebhookPayload(replacementValue, part)
596-
}
579+
// Fallback to webhook metadata payload if present
580+
nextValue = resolveFromWebhookPayload(replacementValue, part)
597581
}
598582
replacementValue = nextValue
599583
}
@@ -765,10 +749,7 @@ export class InputResolver {
765749

766750
let replacementValue: any = blockState.output
767751

768-
// Merge nested github object onto root to make <block.repository> resolve transparently
769-
if (replacementValue && typeof replacementValue === 'object' && replacementValue.github && typeof replacementValue.github === 'object') {
770-
replacementValue = { ...replacementValue.github, ...replacementValue }
771-
}
752+
// Do not merge nested provider aliases. Expect payload fields at the root.
772753

773754
for (const part of pathParts) {
774755
if (!replacementValue || typeof replacementValue !== 'object') {
@@ -800,15 +781,11 @@ export class InputResolver {
800781

801782
replacementValue = arrayValue[index]
802783
} else {
803-
// Regular property access with a GitHub alias fallback
784+
// Regular property access with webhook metadata fallback only
804785
let nextValue = resolvePropertyAccess(replacementValue, part)
805786
if (nextValue === undefined) {
806-
// Fallback to nested github alias if present
807-
nextValue = resolveWithGithubAlias(replacementValue, part)
808-
if (nextValue === undefined) {
809-
// Fallback to webhook metadata payload if present
810-
nextValue = resolveFromWebhookPayload(replacementValue, part)
811-
}
787+
// Fallback to webhook metadata payload if present
788+
nextValue = resolveFromWebhookPayload(replacementValue, part)
812789
}
813790
replacementValue = nextValue
814791
}

0 commit comments

Comments
 (0)