-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix(copilot): fix webhook triggers unsaving in new diff store #2096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryFixes webhook triggers becoming unsaved when using the new diff store by adding server-side webhook persistence during workflow saves and improved 404 handling in the webhook management hook. Key Changes:
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Frontend
participant SubBlockStore
participant WorkflowAPI
participant WebhookAPI
participant Database
User->>Frontend: Edit workflow with webhook triggers
Frontend->>SubBlockStore: Store webhookId, triggerId, triggerConfig
User->>Frontend: Save workflow
Frontend->>WorkflowAPI: PUT /api/workflows/[id]/state
WorkflowAPI->>Database: Save workflow state to normalized tables
WorkflowAPI->>WorkflowAPI: syncWorkflowWebhooks()
loop For each block with webhookId
WorkflowAPI->>Database: Check if webhook exists
alt Webhook exists
WorkflowAPI->>Database: Update webhook if needed (workflowId, blockId, path)
else Webhook missing (404)
WorkflowAPI->>Database: Recreate webhook with stored metadata
WorkflowAPI->>WorkflowAPI: Log webhook recreation
end
end
WorkflowAPI-->>Frontend: Success response
Note over User,Database: Hook's updateWebhook now handles 404 by recreating
User->>Frontend: Update webhook config later
Frontend->>WebhookAPI: PATCH /api/webhooks/[id]
alt Webhook found
WebhookAPI->>Database: Update providerConfig
WebhookAPI-->>Frontend: Success
else Webhook not found (404)
WebhookAPI-->>Frontend: 404 error
Frontend->>Frontend: useWebhookManagement detects 404
Frontend->>SubBlockStore: Clear webhookId
Frontend->>WebhookAPI: POST /api/webhooks (recreate)
WebhookAPI->>Database: Insert new webhook
Frontend->>SubBlockStore: Store new webhookId
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
| if (needsUpdate) { | ||
| await db | ||
| .update(webhook) | ||
| .set({ | ||
| workflowId, | ||
| blockId: block.id, | ||
| path: triggerPath, | ||
| provider: provider || existing.provider, | ||
| providerConfig: Object.keys(providerConfig).length | ||
| ? providerConfig | ||
| : existing.providerConfig, | ||
| isActive: true, | ||
| updatedAt: new Date(), | ||
| }) | ||
| .where(eq(webhook.id, webhookId)) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: only updates webhook if blockId, workflowId, or path changed, but doesn't update providerConfig or provider if they changed but those fields stayed the same
this means if a user updates their trigger configuration (e.g., changes credentials or trigger settings), those changes won't be persisted to the webhook during workflow save unless the blockId/workflowId/path also changed
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/api/workflows/[id]/state/route.ts
Line: 339:354
Comment:
**logic:** only updates webhook if `blockId`, `workflowId`, or `path` changed, but doesn't update `providerConfig` or `provider` if they changed but those fields stayed the same
this means if a user updates their trigger configuration (e.g., changes credentials or trigger settings), those changes won't be persisted to the webhook during workflow save unless the blockId/workflowId/path also changed
How can I resolve this? If you propose a fix, please make it concise.
Summary
Brief description of what this PR does and why.
Fixes #(issue)
Type of Change
Testing
How has this been tested? What should reviewers focus on?
Checklist
Screenshots/Videos