Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • strip extraneous fields from trigger processing
  • move all webhook/trigger-specific logic to the formatWebhookInput for a single source of truth

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 6, 2026 0:07am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 6, 2026

Greptile Summary

This PR refactors webhook/trigger processing to centralize logic in formatWebhookInput, eliminating 88 lines of duplicated provider-specific formatting from trigger-handler.ts.

Key changes:

  • Removed complex provider-specific logic (github, microsoft-teams, gmail, outlook, etc.) from TriggerBlockHandler.execute()
  • Replaced with simple destructuring: const { webhook, workflowId, ...cleanOutput } = starterOutput
  • Updated formatWebhookInput for gmail and outlook to include webhook and workflowId fields (matching other providers)
  • Added filtering in BlockExecutor.filterOutputForLog() to strip internal fields (webhook, workflowId, input) from trigger logs
  • Establishes formatWebhookInput as single source of truth for webhook data structure

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The refactoring improves code maintainability by consolidating webhook formatting logic into a single location. The changes are well-structured, reduce complexity, and the existing test suite validates the functionality remains intact.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/executor/handlers/trigger/trigger-handler.ts Removed complex provider-specific logic (88 lines) and replaced with simple destructuring that strips webhook and workflowId fields
apps/sim/lib/webhooks/utils.server.ts Added webhook and workflowId fields to gmail and outlook formatters to centralize webhook data structure
apps/sim/executor/execution/block-executor.ts Added filtering logic to strip internal fields (webhook, workflowId, input) from trigger block logs

Sequence Diagram

sequenceDiagram
    participant Webhook as Webhook Request
    participant FWI as formatWebhookInput()
    participant TH as TriggerBlockHandler
    participant BE as BlockExecutor
    participant Log as Block Logs

    Webhook->>FWI: Incoming webhook data
    Note over FWI: Single source of truth<br/>for all providers
    FWI->>FWI: Format provider-specific data
    FWI->>FWI: Add webhook metadata
    FWI->>FWI: Add workflowId
    FWI-->>TH: Formatted output with<br/>webhook & workflowId

    TH->>TH: Check if webhook.data exists
    alt Has webhook data
        TH->>TH: Destructure: { webhook, workflowId, ...cleanOutput }
        TH-->>BE: Return cleanOutput<br/>(without internal fields)
    else No webhook data
        TH-->>BE: Return starterOutput as-is
    end

    BE->>BE: filterOutputForLog()
    alt Is trigger block
        BE->>BE: Strip webhook, workflowId, input
        BE-->>Log: Filtered output
    else Not trigger
        BE-->>Log: Full output
    end
Loading

@waleedlatif1 waleedlatif1 merged commit cc3f565 into staging Jan 6, 2026
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/webhook branch January 6, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants