fix(trigger-dup): on duplicate trigger should not point at old webhook row#1784
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Fixed a bug where duplicating trigger blocks would cause the duplicate to reference the original webhook database row, leading to incorrect webhook associations.
The fix introduces a constant WEBHOOK_SUBBLOCK_FIELDS containing ['webhookId', 'triggerPath'] and filters these fields out in three key locations:
- Duplication flow (
use-collaborative-workflow.ts): Excludes webhook fields when creating duplicate block payload and merging subblock values - Collaborative operations (
use-collaborative-workflow.ts): Prevents webhook fields from being applied when receiving 'add' and 'duplicate' socket operations - State merging (
utils.ts,server-utils.ts): Skips webhook fields in both client and server-side merge operations
This ensures duplicated trigger blocks generate new webhooks instead of pointing to the original block's webhook.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The fix is surgical and targeted - it consistently excludes webhook-specific fields across all relevant code paths using a well-defined constant. The implementation is defensive (using
includes()checks) and follows the existing patterns in the codebase. The changes were manually tested and don't introduce any breaking changes to existing functionality. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/hooks/use-collaborative-workflow.ts | 5/5 | Added filtering logic to exclude webhookId and triggerPath fields when duplicating blocks and applying subblock values, preventing duplicated trigger blocks from referencing the original webhook |
| apps/sim/stores/workflows/server-utils.ts | 5/5 | Added webhook field exclusion to mergeSubblockState function to prevent webhook-specific fields from being persisted during server-side operations |
| apps/sim/stores/workflows/utils.ts | 5/5 | Added webhook field filtering to both sync and async versions of mergeSubblockState, ensuring webhook-specific fields are excluded from state merging operations |
Sequence Diagram
sequenceDiagram
participant User
participant UI as Workflow UI
participant Hook as useCollaborativeWorkflow
participant SubBlockStore
participant WorkflowStore
participant Socket as Socket Server
User->>UI: Duplicate trigger block
UI->>Hook: duplicateBlock(sourceId)
Note over Hook: Get source block & subblock values
Hook->>SubBlockStore: Get subblock values for sourceId
SubBlockStore-->>Hook: All subblock values (including webhookId, triggerPath)
Note over Hook: Filter webhook-specific fields
Hook->>Hook: Filter out webhookId & triggerPath from subBlockValues
Hook->>Hook: Delete webhookId & triggerPath from mergedSubBlocks
Note over Hook: Create duplicate with new ID
Hook->>Socket: Emit 'duplicate' operation
Socket->>WorkflowStore: Create new block (without webhook fields)
Socket->>SubBlockStore: Set subblock values (excluding webhook fields)
Note over Socket: Apply subblock values (collaborative)
Socket->>SubBlockStore: Skip webhookId & triggerPath during setValue
WorkflowStore-->>UI: New block created
Note over UI: Duplicated block has no webhook reference<br/>New webhook will be created when saved
3 files reviewed, no comments
waleedlatif1
pushed a commit
that referenced
this pull request
Nov 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On duplicating trigger block should not point at old webhook row.
Type of Change
Testing
Tested manually with @waleedlatif1
Checklist