-
Notifications
You must be signed in to change notification settings - Fork 3.2k
improvement(webhooks): lifecycle management with external providers, remove save configuration #2831
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 SummaryRefactors webhook lifecycle management to occur during workflow deployment rather than requiring a separate "Save Configuration" button. This significantly improves UX by removing a manual step. Key Changes
Implementation DetailsThe new flow:
Webhook recreation is intelligently triggered when relevant config changes are detected (via Issues Found
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant UI as Deploy Modal
participant API as Deploy API
participant Deploy as saveTriggerWebhooksForDeploy
participant Provider as Provider Subscriptions
participant External as External Provider APIs
participant DB as Database
User->>UI: Click Deploy
UI->>API: POST /api/workflows/{id}/deploy
API->>API: Validate permissions & schedules
API->>Deploy: saveTriggerWebhooksForDeploy()
loop For each trigger block
Deploy->>Deploy: Resolve trigger ID & build config
Deploy->>Deploy: Validate required fields
alt Credential Set
Deploy->>DB: syncWebhooksForCredentialSet()
DB->>DB: Create webhooks for each credential
else Single Credential
Deploy->>DB: Query existing webhook
alt Webhook exists
Deploy->>Provider: shouldRecreateExternalWebhookSubscription()
alt Config changed
Provider->>External: cleanupExternalWebhook()
Provider->>External: createExternalWebhookSubscription()
External-->>Provider: Return external ID
end
Deploy->>DB: Update webhook record
else New webhook
Provider->>External: createExternalWebhookSubscription()
External-->>Provider: Return external ID
Deploy->>DB: Insert webhook record
end
end
end
Deploy-->>API: Success/Error
API->>DB: deployWorkflow()
API->>DB: createSchedulesForDeploy()
API-->>UI: Deployment result
UI-->>User: Show success or error
|
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.
17 files reviewed, 1 comment
| const finalProviderConfig = { | ||
| ...nextProviderConfig, | ||
| credentialId: existingConfig.credentialId, | ||
| credentialSetId: existingConfig.credentialSetId, | ||
| userId: existingConfig.userId, | ||
| historyId: existingConfig.historyId, | ||
| lastCheckedTimestamp: existingConfig.lastCheckedTimestamp, | ||
| setupCompleted: existingConfig.setupCompleted, | ||
| externalId: nextProviderConfig.externalId ?? existingConfig.externalId, | ||
| } |
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: Credential fields from existingConfig always override nextProviderConfig, even when new credentials are provided
The merge logic preserves credentialId and credentialSetId from the existing config unconditionally. If a user updates credentials during redeployment, the new values in providerConfig will be overwritten with old values.
Consider checking if new credential values are present in providerConfig before falling back to existing ones:
| const finalProviderConfig = { | |
| ...nextProviderConfig, | |
| credentialId: existingConfig.credentialId, | |
| credentialSetId: existingConfig.credentialSetId, | |
| userId: existingConfig.userId, | |
| historyId: existingConfig.historyId, | |
| lastCheckedTimestamp: existingConfig.lastCheckedTimestamp, | |
| setupCompleted: existingConfig.setupCompleted, | |
| externalId: nextProviderConfig.externalId ?? existingConfig.externalId, | |
| } | |
| const finalProviderConfig = { | |
| ...nextProviderConfig, | |
| credentialId: providerConfig.credentialId ?? existingConfig.credentialId, | |
| credentialSetId: providerConfig.credentialSetId ?? existingConfig.credentialSetId, | |
| userId: existingConfig.userId, | |
| historyId: existingConfig.historyId, | |
| lastCheckedTimestamp: existingConfig.lastCheckedTimestamp, | |
| setupCompleted: existingConfig.setupCompleted, | |
| externalId: nextProviderConfig.externalId ?? existingConfig.externalId, | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/webhooks/deploy.ts
Line: 359:368
Comment:
**logic:** Credential fields from `existingConfig` always override `nextProviderConfig`, even when new credentials are provided
The merge logic preserves `credentialId` and `credentialSetId` from the existing config unconditionally. If a user updates credentials during redeployment, the new values in `providerConfig` will be overwritten with old values.
Consider checking if new credential values are present in `providerConfig` before falling back to existing ones:
```suggestion
const finalProviderConfig = {
...nextProviderConfig,
credentialId: providerConfig.credentialId ?? existingConfig.credentialId,
credentialSetId: providerConfig.credentialSetId ?? existingConfig.credentialSetId,
userId: existingConfig.userId,
historyId: existingConfig.historyId,
lastCheckedTimestamp: existingConfig.lastCheckedTimestamp,
setupCompleted: existingConfig.setupCompleted,
externalId: nextProviderConfig.externalId ?? existingConfig.externalId,
}
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
Will do webhook lifecycle management as part of deploy process.
Type of Change
Testing
Tested manually
Checklist