Skip to content

improvement(execution): trigger manual execution using mock payloads - #1863

Merged
icecrasher321 merged 8 commits into
stagingfrom
fix/update-err-message
Nov 9, 2025
Merged

improvement(execution): trigger manual execution using mock payloads#1863
icecrasher321 merged 8 commits into
stagingfrom
fix/update-err-message

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Can trigger all triggers manually. Will run with a mock payload for integration triggers.

Type of Change

  • Other: UX Improvement

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

vercelBot commented Nov 9, 2025

Copy link
Copy Markdown

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

ProjectDeploymentPreviewCommentsUpdated (UTC)
docsReadyReadyPreviewCommentNov 9, 2025 4:26am

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR enables manual execution of all trigger types (including external webhooks and integrations) by generating mock payloads from trigger output definitions.

Key Changes:

  • Added mock payload generation system that dynamically creates test data from trigger outputs schema using generateMockPayloadFromOutputsDefinition()
  • Implemented multi-trigger support with path-based grouping via selectBestTrigger() to handle workflows with multiple disjoint execution paths
  • Added EXTERNAL_TRIGGER to manual execution priorities, allowing webhooks/integrations to run manually
  • Removed hardcoded sample payloads from 60+ trigger files - now auto-generated from outputs at runtime via getTrigger()
  • Removed filterEdgesFromTriggerBlocks() utility as trigger-to-trigger edge prevention now happens at creation time

Architecture:
The system determines if a trigger needs mock data using triggerNeedsMockPayload() (true for webhooks/integrations, false for schedules/manual triggers). For external triggers, it extracts the trigger ID from block metadata and generates structured mock data matching the trigger's output schema. The mock payload generator recursively processes nested output structures to create realistic test data.

Impact:
Significantly improves developer experience by allowing testing of webhook-triggered workflows without external events. Mock payloads maintain type consistency with actual webhook data since they're generated from the same output definitions.

Confidence Score: 4/5

  • This PR is mostly safe to merge with one logical issue requiring attention
  • The implementation is well-structured with comprehensive mock payload generation and multi-trigger support. However, there's a critical issue in processOutputField at apps/sim/lib/workflows/trigger-utils.ts:50 that could cause infinite recursion if trigger outputs contain circular references. While unlikely in practice (since outputs are typically defined as plain objects), this should be fixed before merge.
  • apps/sim/lib/workflows/trigger-utils.ts requires fixing the circular reference protection in processOutputField

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/lib/workflows/trigger-utils.ts4/5Added comprehensive mock payload generation logic from trigger outputs, plus trigger selection and grouping by execution paths
apps/sim/lib/workflows/triggers.ts5/5Added EXTERNAL_TRIGGER to manual execution priorities and improved block classification with registry fallback
apps/sim/lib/workflows/executor/execution-core.ts5/5Removed edge filtering logic since trigger-to-trigger edges are prevented at creation time
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts4/5Implemented multi-trigger support with path-based grouping, mock payload generation for external triggers, and improved error handling
apps/sim/triggers/index.ts4/5Auto-generates and injects samplePayload subblocks dynamically from trigger outputs definition

Sequence Diagram

sequenceDiagram
participant User
participant UI as Workflow UI
participant Hook as useWorkflowExecution
participant Utils as TriggerUtils
participant API as /api/workflows/[id]/execute
participant Core as ExecutionCore
participant Executor
User->>UI: Click "Run Workflow" button
UI->>Hook: executeWorkflow()
Note over Hook: Resolve start candidates
Hook->>Utils: resolveStartCandidates(blocks, 'manual')
Utils-->>Hook: Array of trigger candidates
Note over Hook: Select best trigger per path
Hook->>Utils: selectBestTrigger(candidates, edges)
Utils->>Utils: groupTriggersByPath()
Utils->>Utils: selectBestFromGroup()
Utils-->>Hook: Selected trigger(s)
alt External Trigger (webhook/integration)
Hook->>Utils: triggerNeedsMockPayload(trigger)
Utils-->>Hook: true
Hook->>Utils: extractTriggerMockPayload(trigger)
Utils->>Utils: getTrigger(triggerId)
Utils->>Utils: generateMockPayloadFromOutputsDefinition()
Utils-->>Hook: Mock payload data
else Manual/API/Input Trigger
Hook->>Hook: Use test values from inputFormat
end
Hook->>API: POST with input & startBlockId
API->>Core: executeWorkflowCore()
alt No startBlockId provided
Core->>Utils: findStartBlock(blocks, executionKind)
Utils-->>Core: Resolved trigger block
end
Core->>Executor: execute(workflow, input)
Executor-->>Core: Execution result
Core-->>API: Result
API-->>Hook: Response
Hook-->>UI: Update execution state
UI-->>User: Show execution results
Loading

61 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment threadapps/sim/lib/workflows/trigger-utils.ts Outdated
@icecrasher321
icecrasher321 merged commit 75ce888 into stagingNov 9, 2025
9 checks passed
@waleedlatif1waleedlatif1 mentioned this pull request Nov 9, 2025
10 tasks
@waleedlatif1
waleedlatif1 deleted the fix/update-err-message branch November 11, 2025 02:21
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
…1863)
* fix(err-message): manual run message
* make external triggers start workflow manually too
* improvement(execution): trigger manual execution using mock payloads
* remove redundant code and update generate mock value func
* cleanup code, add to docs
* fix multi trigger injection
* address greptile comments
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
…1863)
* fix(err-message): manual run message
* make external triggers start workflow manually too
* improvement(execution): trigger manual execution using mock payloads
* remove redundant code and update generate mock value func
* cleanup code, add to docs
* fix multi trigger injection
* address greptile comments
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
Sign up for freeto 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.

1 participant

@icecrasher321