[CAL-3736] All webhooks are being triggered, despite not being subscribed to the specific event type
Issue Summary
I have two webhooks, one for dev env and the other for prod. I created a test call and it only subscribes to the dev webhook.
However, when I book a test call, both webhooks are triggered.
I double-checked, and the dev webhook also gets triggered on prod bookings.
Steps to Reproduce
- Create two webhooks.
- Create an event type.
- Go to event type settings and subscribe it to one webhook only
- Book a call of that type.
- Notice that both webhooks are triggered, despite one of them never subscribed to the webhook.
Actual Results
- All active webhooks are being triggered for all event types.
- An event type was able to trigger a webhook that is not instructed to listen to this event type.
Expected Results
- I expect that an event type only triggers the subscribed webhooks and not all the active ones.
- I expect that newly created event types do not trigger existing webhooks unless explicitly stated in the event type settings.
Technical details
- Irrelevant; I do not self-host; no code is involved, only interface.
Evidence
- The
Test Callonly has one webhook activated
- Both active webhooks are triggered.
Hey @ahmad-ali14, great to see you back! Hope everything else is going smoothly for you besides this little hiccup. Let's dive into this and see how we can sort it out together.
Thank you for the detailed report. Based on the information you've provided, it seems like there might be an issue with how Cal.com is handling webhook subscriptions and triggers.
From the system's design, when an event type is created and subscribed to a webhook, only that specific webhook should be triggered when the event occurs. However, in your case, it seems like all active webhooks are being triggered, regardless of their subscription status. This behavior is not expected and could be a potential bug.
The system determines which webhooks to trigger based on several factors such as event type, user information, specific trigger events, team information, and subscriber preferences. It uses a combination of these to filter for relevant webhooks and then schedules or sends the appropriate payloads to the registered subscribers. You can find more details about this in the handleConfirmation.ts file.
As for the Cal.com interface, it handles the configuration of webhooks through a combination of React state management, form handling, and TRPC queries and mutations. The interface is designed to robustly handle webhook configurations by validating input, providing clear user feedback, and ensuring data consistency. You can find more details about this in the EventWebhooksTab.tsx file.
Given this, it's possible that there might be a bug in the system that's causing all active webhooks to be triggered, regardless of their subscription status. To further investigate this issue, it would be helpful if you could provide the following additional information:
- The exact steps you took when setting up the webhooks and event types.
- Any error messages or logs you received when the issue occurred.
- Screenshots or screen recordings of the issue, if possible.
This information will help us understand the issue better and find a potential solution. Thank you for your patience and cooperation.
Sources
- packages/features/webhooks/lib/scheduleTrigger.ts
- packages/features/bookings/lib/handleConfirmation.ts
- apps/web/components/eventtype/EventWebhooksTab.tsx
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Hey @ahmad-ali14, as per what I understand. All the webhooks you create from the following page https://app.cal.com/settings/developer/webhooks are subscribed to all the event-types in your account.
To set a webhook for a particular event-type, you need to add it to the edit page of event-type https://app.cal.com/event-types/eventId?tabName=webhooks.
Hey @thepradipvc, thank you for your response.
It was not clear from the UI or documentation.
I was expecting that you would create all my webhooks from https://app.cal.com/settings/developer/webhooks and then under the settings of each event type, I would choose what webhook(s) that the type should subscribe to.
So that means; if I want a per-eventType webhook experience; I should delete all webhooks created from https://app.cal.com/settings/developer/webhooks and create webhooks only from https://app.cal.com/event-types/eventId?tabName=webhooks?
This way I will have unique webhooks per-eventType, even if I use the same URL?
Yes, this is what I found while testing the webhooks to understand your problem. Also there is no way to select from the global webhooks created from settings in a particular event-type webhooks settings. So this confirms that it will be as per my understanding only.
You should try deleting the global webhooks and create separate webhooks for each event-type as it works as per your requirement at this moment at least.
I'm not sure if this is intended behaviour or the maintainers might choose to change it in future.
Hope this helps 😊
@thepradipvc Thank you very much; I will try this and update the issue.
I noticed that the webhook object can have only one eventType id although you would expect one-to-many relationship.
But yeah, someone needs to update the docs as this is really cpunter intuitive.
But yeah, someone needs to update the docs as this is really cpunter intuitive.
Yes, the docs are misleading. Should we mention any maintainer here to look at the issue?
Yes, the docs are misleading. Should we mention any maintainer here to look at the issue?
Yes please.
Hey @PeerRich, I don't know whom to mention for such an issue but I know you are one of the maintainers so I mentioned you. Can you confirm from our above discussion if the documentation needs to be updated?
hey this has been under my radar, apologies. we are prioritizising this urgently!
@thepradipvc Thank you for the help explaining how our webhooks currently work 🙏 Like you said, you can either create a global webhook that triggers for all event types or an event type specific webhook. Maybe we change that one day, but it's not high priority right now
But yeah, someone needs to update the docs as this is really cpunter intuitive.
I will make sure to update our docs to make this more clear