Fix/webhook cascade#2591
Conversation
…webhook-cascade
…webhook-cascade
🦋 Changeset detectedLatest commit: da12dcd The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@Aryainguz is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
Deep Review✅ No critical issues found. The change is correctly team-scoped on both the count query and the delete, 🟡 P2 — recommended
🔵 P3 nitpicks (5)
Reviewers (8): correctness, security, testing, api-contract, maintainability, kieran-typescript, reliability, project-standards. Testing gaps:
|
|
Thanks for taking a look at this @Aryainguz
This is indeed a problem, but IMO this change makes it slightly worse than before because the user can still silently kill many alerts, but now the alert history UI does not indicate any problem to the user. As the alert task is currently implemented, alerts with a broken Webhook reference will still be evaluated and save their state to the AlertHistory. So the alerts haven't died, their state is just shadowed in the AlertHistory UX with the webhook error. So I think that a better approach here might be to either:
|
@pulpdrew yeah agreed that silently nullifying alert channels is worse than erroring. I think we should go with Option 1. The delete endpoint will return a 409 Conflict listing the alert count, so the user knows to migrate those alerts first before deleting. I think this is better but let me know your thoughts. I've updated code and test cases as per this as well Initial idea of implementation before that user don't delete the alert and usually update webhooks only but I agree it's not correct, and your options 1 sounds best |
|
@Aryainguz thanks! Although now that the API errors, could we show a mantine notification or other indicator the user when the delete errors, so that they are aware why the deletion is failing? Also cc @jordan-simonovski in regards to #2586 in case we want to make the new external webhooks DELETE API consistent with this behavior. |
@pulpdrew The frontend already handles this! The DeleteWebhookButton in WebhooksSection.tsx catches HTTPError, extracts the .message from the JSON response, and shows it as a red Mantine notification toast for 5 seconds. So when the 409 fires, the user will see: "Cannot delete webhook: N alert(s) still reference it. Please update or remove those alerts first." So no frontend changes needed for this Attaching image and video for same
2026-07-07.20-22-29.mov |
pulpdrew
left a comment
There was a problem hiding this comment.
My mistake, thanks for confirming that the UI shows the notification! LGTM, thanks for the contribution.

Summary
Deleting a webhook left every alert whose
channel.webhookIdpointed at it broken indefinitely silently loggingWEBHOOK_ERRORon every evaluation tick without any user-visible notice.A user can delete a webhook (to rotate credentials, rename it, etc.) not realising that every alert attached to it just died silently.
This fix nulls the
channelfield on all referencing alerts before the webhook is removed, so they continue to evaluate but no longer attempt delivery to the deleted endpoint. The alert data, thresholds, and history are fully preserved.Dashboard deletion cascades via
deleteDashboardAlerts; SavedSearch deletion viadeleteSavedSearchAlerts. Webhook deletion had no equivalent this PR closes that gap.Fixes #2590
Changed file:
packages/api/src/routers/api/webhooks.tsChanges:
packages/api/src/routers/api/webhooks.ts: AddedAlert.updateManyinside theDELETE /:idhandler to cascade-null the channel of all attached alerts.packages/api/src/routers/api/__tests__/webhooks.test.ts: Added an integration test verifying the cascade correctly nulls the alert channel in the database when the webhook is deleted./.changeset/fix-webhook-cascade-delete.mdLocal Validations