Netlify Outgoing Webhooks sending random false triggers

Hi! I am using netlify outgoing webhooks to send my site deploy status updates to my backend endpoint. I have successfully configured the weebhooks endpoint and enabled the webhook event on netlify deploy settings as well.
But on my backend when a deploy fails on single website netlify is sending request on my backend for error message 4 to 5 times for no reason.
Same is the case when site is successfully build I still recieve error events from webhook for no reason.
Here in this image you can see for a single time failure netlify webhooks sent notification twice and sometimes thrice for no reason.
image
Please can you guide me on that what can be the issue or potential fix for that.
In future I’m planning to use netlify api to enable webhooks automatically rather than doing this manually from the dashboard settings page of netlify.
Thanks!
Hadi

Hey @detosk,
Can you please share the Netlify url that this hook is connected to? We have fairly limited visibility into webhook logs, but we can definitely take a look and see if we see anything that would explain this behavior.

https://fdbfdc530ea3.ngrok.io/api/v1/netlify-deploy-hooks
Hi, this was the link I tested my webhook on you can see for same site failure single time I recieved 6 post requests with same status and error message.
Thank you!

Thanks!

I see some really weird notifications configured in the database that don’t show up in our UI (here: https://app.netlify.com/sites/admiring-wright-58c935/settings/deploys#outgoing-notifications). Were you attempting to add them via API or something? IF not, could you confirm that you don’t need any not shown at the URL I listed, around deploys? In that case I’ll be able to remove the rest from the database so we stop over-reporting :slight_smile:

This was a test account. But in production I’m trying to add this for a saas based business solution. I added two outgoing webhooks for deploy fail and success using netlify api. Our platform will have over 100+ websites published through netlify. In order to track site status either it’s up and running or build failed it is over reporting and sending duplicate notifications in my case a single time site fails to deploy it sends 7 error notifications. I would have if you can fix this issue would save us alot of effort at our end. I just need outgoing webhooks for fail and success to be added through netlify api endpoint and work properly. :grinning:

Adding via API works fine, if you follow the correct syntax. That’s how our UI adds them :wink:

You can add only one hook at a time, not an array of them which I think you did on that test account.

If you have a non-test site where something is wrong, please link me to it and I will advise about it, instead.

I enabled each webhook by sending seperate requests to netlify api. To enable failure webhook I send request seperately and to enable success webhook i send request seperate with site ID to enable that webhook. The behavior remains same when my store build fails it send 6 duplicate requests to my webhook endpoint with same message same goes for success case.
I have fixed it for time being by checking if previous status is same as new one in database so I dont insert new row in database to store extra logs. But I would like that if this issue is fixed in future.

Hi, @detosk. I don’t think there is anything to fix. It appears you used our API to create multiple webhooks. The reason that you get multiple notifications if because you created multiple. Netlify is only doing what you told it to do using our API. If you do not create multiple webhooks then this won’t happen.

@fool was asking for a site where you were not doing testing of the API.

If you want to fix the site with the multiple notification (the site where you were testing our API) my suggestion would be for our Netlify support team to delete all the of webhooks and you can start over. Would you like us to delete all the configured notifications for that site so you can start from scratch?

Hi @detosk,

I faced an exact issue recently. I had an ExpressJS app running in my local computer and I wanted one of it’s endpoint to be called by Netlify and before deploying it on higher environment, I wanted to make sure it works properly so I used ngrok to expose the backend on internet and configured that in one of my netlify app to be called on deploy success. And to my surprise it was getting called 9 times.

But when I deployed the app on Heroku, the endpoint just got called once.

I’m not sure if I did some code changes or was it just Netlify that called my Heroku instance once, but you may make sure that when you’re running locally after all the logging and debugging is done return a 200 status back to Netlify. This is important.
I say this because if you configure a wrong webhook to Netlify, it will call it multiple times before failing completely. And once it fails, you’ll have to edit the url to make the webhook working again.

And if that still doesn’t work for you, here’s a solution that I thought of when I faced the above situation. In the POST webhook call of Netlify, there’s a unique build id sent as build_id. You can store this build_id in a redis and check against it when you get a subsequent call before proceeding for further actions. You can set a time to expire this build_id for 24 hours or 48 hours.
You can also store it locally in a file and check against that (But you’ll have to write a lot of extra code for maintaining and modifying file for that). But in either case remember to return a 200 response to Netlify, otherwise it will start failing.