Webhooks do not work when performing updates in bulk mode #6126

Closed
opened 2025-12-29 19:37:02 +01:00 by adam · 7 comments
Owner

Originally created by @ane-ruiz on GitHub (Feb 21, 2022).

NetBox version

3.1.7

Python version

3.8

Steps to Reproduce

I am using netbox webhooks to launch an Ansible playbook (via Jenkins). The idea is to launch the playbook every time we update a device interface. Doing this individually works fine. The problem is that when editing several interfaces at the same time (in bulk mode by selecting the check-box), the webhook only does it for one of them (for the first one that makes the change, I understand).

The webhook I have configured:

webhook

When I edit the object interface (edit a single interface), for example GigabitEthernet1/0/1 in this case:

edit_1_int

The webhook works correctly, in Jenkins (Ansible), I get the following information from "Data (.data as JSON)" after the HTTP post:

{"event": "updated", "timestamp": "2022-02-21 10:04:16.427434+00:00", "model": "interface", "username": "0205491", "request_id": "92738c7b-95b9-44b5-884e-17bd46dabef8", "data": {"id": 16491, "url": "/api/dcim/interfaces/16491/", "display": "GigabitEthernet1/0/1", "device": {"id": 2857, "url": "/api/dcim/devices/2857/", "display": "BCN_P39_prueba", "name": "BCN_P39_prueba"}, "name": "GigabitEthernet1/0/1", "label": "", "type": {"value": "1000base-t", "label": "1000BASE-T (1GE)"}, "enabled": true, "parent": null, "bridge": null, "lag": null, "mtu": null, "mac_address": null, "wwn": "", "mgmt_only": false, "description": "Prueba webhook", "mode": {"value": "access", "label": "Access"}, "rf_role": null, "rf_channel": null, "rf_channel_frequency": null, "rf_channel_width": null, "tx_power": null, "untagged_vlan": {"id": 330, "url": "/api/ipam/vlans/330/", "display": "GESTION (252)", "vid": 252, "name": "GESTION"}, "tagged_vlans": [], "mark_connected": false, "cable": null, "wireless_link": null, "link_peer": null, "link_peer_type": null, "wireless_lans": [], "connected_endpoint": null, "connected_endpoint_type": null, "connected_endpoint_reachable": null, "tags": [{"id": 1, "url": "/api/extras/tags/1/", "display": "BCN_ap_int", "name": "BCN_ap_int", "slug": "bcn_ap_int", "color": "8bc34a"}], "custom_fields": {}, "created": "2021-09-01", "last_updated": "2022-02-21T11:04:16.316469+01:00", "count_ipaddresses": 0, "count_fhrp_groups": 0, "_occupied": false}, "snapshots": {"prechange": {"created": "2021-09-01", "last_updated": "2022-02-17T15:54:55.466Z", "device": 2857, "name": "GigabitEthernet1/0/8", "label": "", "description": "AP Controller", "cable": null, "mark_connected": false, "enabled": true, "mac_address": null, "mtu": null, "mode": "access", "parent": null, "bridge": null, "lag": null, "type": "1000base-t", "mgmt_only": false, "wwn": null, "rf_role": "", "rf_channel": "", "rf_channel_frequency": null, "rf_channel_width": null, "tx_power": null, "wireless_link": null, "untagged_vlan": 330, "wireless_lans": [], "tagged_vlans": [], "custom_fields": {}, "tags": ["BCN_ap_int"]}, "postchange": {"created": "2021-09-01", "last_updated": "2022-02-21T10:04:16.316Z", "device": 2857, "name": "GigabitEthernet1/0/1", "label": "", "description": "Prueba webhook", "cable": null, "mark_connected": false, "enabled": true, "mac_address": null, "mtu": null, "mode": "access", "parent": null, "bridge": null, "lag": null, "type": "1000base-t", "mgmt_only": false, "wwn": "", "rf_role": "", "rf_channel": "", "rf_channel_frequency": null, "rf_channel_width": null, "tx_power": null, "wireless_link": null, "untagged_vlan": 330, "wireless_lans": [], "tagged_vlans": [], "custom_fields": {}, "tags": ["BCN_ap_int"]}}}

This result is correct, the webhook here works correctly.
The problem is when I want to edit more than one interface at a time (for example, to make the same changes on all of them, I select several interfaces in the list of device interfaces):

edit_interface

When I edit the interfaces in this way, the result I get is only that of the first selected interface. I only receive the "data" (the update information) for one of the interfaces. In the tests I have made, I only receive the information of the first interface of the selected group/list (the information of that interface arrives in the same format that I have indicated in the correct result).

This way, it seems that the webhook is launched only once, as if only one object (in this case interfaces) has been modified, instead of applying the webhook for each update.

How can I get the information of the 3 simultaneous changes (in this example)?

Expected Behavior

What I would like is for the Webhook option to launch as many webhooks as interfaces you modify. I don't know if there is a way to make it work in bulk mode to make several changes simultaneously.

If there is a way, could you point me in the right direction? If not, will it be possible in an update?

Observed Behavior

Currently it only executes a single webhook action that applies to a single object (in my case, a single interface).

I hope you can help me.
Thank you very much!!

Originally created by @ane-ruiz on GitHub (Feb 21, 2022). ### NetBox version 3.1.7 ### Python version 3.8 ### Steps to Reproduce I am using netbox webhooks to launch an Ansible playbook (via Jenkins). The idea is to launch the playbook every time we update a device interface. Doing this individually works fine. The problem is that when editing several interfaces at the same time (in bulk mode by selecting the check-box), the webhook only does it for one of them (for the first one that makes the change, I understand). The webhook I have configured: ![webhook](https://user-images.githubusercontent.com/99812647/154964637-aafd1e36-bfe5-4cf8-9edf-9d1766b3fc48.png) When I edit the object interface (edit a single interface), for example GigabitEthernet1/0/1 in this case: ![edit_1_int](https://user-images.githubusercontent.com/99812647/154965130-b68387fd-09fc-4bf5-92b0-42f34ba1475d.png) The webhook works correctly, in Jenkins (Ansible), I get the following information from "Data (.data as JSON)" after the HTTP post: `{"event": "updated", "timestamp": "2022-02-21 10:04:16.427434+00:00", "model": "interface", "username": "0205491", "request_id": "92738c7b-95b9-44b5-884e-17bd46dabef8", "data": {"id": 16491, "url": "/api/dcim/interfaces/16491/", "display": "GigabitEthernet1/0/1", "device": {"id": 2857, "url": "/api/dcim/devices/2857/", "display": "BCN_P39_prueba", "name": "BCN_P39_prueba"}, "name": "GigabitEthernet1/0/1", "label": "", "type": {"value": "1000base-t", "label": "1000BASE-T (1GE)"}, "enabled": true, "parent": null, "bridge": null, "lag": null, "mtu": null, "mac_address": null, "wwn": "", "mgmt_only": false, "description": "Prueba webhook", "mode": {"value": "access", "label": "Access"}, "rf_role": null, "rf_channel": null, "rf_channel_frequency": null, "rf_channel_width": null, "tx_power": null, "untagged_vlan": {"id": 330, "url": "/api/ipam/vlans/330/", "display": "GESTION (252)", "vid": 252, "name": "GESTION"}, "tagged_vlans": [], "mark_connected": false, "cable": null, "wireless_link": null, "link_peer": null, "link_peer_type": null, "wireless_lans": [], "connected_endpoint": null, "connected_endpoint_type": null, "connected_endpoint_reachable": null, "tags": [{"id": 1, "url": "/api/extras/tags/1/", "display": "BCN_ap_int", "name": "BCN_ap_int", "slug": "bcn_ap_int", "color": "8bc34a"}], "custom_fields": {}, "created": "2021-09-01", "last_updated": "2022-02-21T11:04:16.316469+01:00", "count_ipaddresses": 0, "count_fhrp_groups": 0, "_occupied": false}, "snapshots": {"prechange": {"created": "2021-09-01", "last_updated": "2022-02-17T15:54:55.466Z", "device": 2857, "name": "GigabitEthernet1/0/8", "label": "", "description": "AP Controller", "cable": null, "mark_connected": false, "enabled": true, "mac_address": null, "mtu": null, "mode": "access", "parent": null, "bridge": null, "lag": null, "type": "1000base-t", "mgmt_only": false, "wwn": null, "rf_role": "", "rf_channel": "", "rf_channel_frequency": null, "rf_channel_width": null, "tx_power": null, "wireless_link": null, "untagged_vlan": 330, "wireless_lans": [], "tagged_vlans": [], "custom_fields": {}, "tags": ["BCN_ap_int"]}, "postchange": {"created": "2021-09-01", "last_updated": "2022-02-21T10:04:16.316Z", "device": 2857, "name": "GigabitEthernet1/0/1", "label": "", "description": "Prueba webhook", "cable": null, "mark_connected": false, "enabled": true, "mac_address": null, "mtu": null, "mode": "access", "parent": null, "bridge": null, "lag": null, "type": "1000base-t", "mgmt_only": false, "wwn": "", "rf_role": "", "rf_channel": "", "rf_channel_frequency": null, "rf_channel_width": null, "tx_power": null, "wireless_link": null, "untagged_vlan": 330, "wireless_lans": [], "tagged_vlans": [], "custom_fields": {}, "tags": ["BCN_ap_int"]}}}` This result is correct, the webhook here works correctly. The problem is when I want to edit more than one interface at a time (for example, to make the same changes on all of them, I select several interfaces in the list of device interfaces): ![edit_interface](https://user-images.githubusercontent.com/99812647/154966476-b2ebaca7-e993-46e4-87f0-80863cde9b44.png) When I edit the interfaces in this way, the result I get is only that of the first selected interface. I only receive the "data" (the update information) for one of the interfaces. In the tests I have made, I only receive the information of the first interface of the selected group/list (the information of that interface arrives in the same format that I have indicated in the correct result). This way, it seems that the webhook is launched only once, as if only one object (in this case interfaces) has been modified, instead of applying the webhook for each update. How can I get the information of the 3 simultaneous changes (in this example)? ### Expected Behavior What I would like is for the Webhook option to launch as many webhooks as interfaces you modify. I don't know if there is a way to make it work in bulk mode to make several changes simultaneously. If there is a way, could you point me in the right direction? If not, will it be possible in an update? ### Observed Behavior Currently it only executes a single webhook action that applies to a single object (in my case, a single interface). I hope you can help me. Thank you very much!!
adam closed this issue 2025-12-29 19:37:02 +01:00
Author
Owner

@jeremystretch commented on GitHub (Feb 21, 2022):

Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

@jeremystretch commented on GitHub (Feb 21, 2022): Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.
Author
Owner

@kkthxbye-code commented on GitHub (Feb 21, 2022):

I just tested this on the demo instance, and it works fine there.

image

I create a webhook for dcim->interface and bulk edited 5 interfaces adding a label (The say failed because I pointed the webhook at localhost). So as Jeremy's respons says, you gotta specify what exactly you are doing for anyone to be able to help you.

@kkthxbye-code commented on GitHub (Feb 21, 2022): I just tested this on the demo instance, and it works fine there. ![image](https://user-images.githubusercontent.com/400797/154966314-d5e88fd4-b827-40ec-89ef-2a76f682b7f9.png) I create a webhook for dcim->interface and bulk edited 5 interfaces adding a label (The say failed because I pointed the webhook at localhost). So as Jeremy's respons says, you gotta specify what exactly you are doing for anyone to be able to help you.
Author
Owner

@ane-ruiz commented on GitHub (Feb 21, 2022):

Hello,

Thank you for your answers, I have just updated the information I had put at the beginning, please check it if you can.

I don't know why this morning I didn't see the "job results", but now I do. In principle this is being done correctly, but I can't get the information of the 3 simultaneous changes of the example:

Job_result

Thank you for your help!

@ane-ruiz commented on GitHub (Feb 21, 2022): Hello, Thank you for your answers, I have just updated the information I had put at the beginning, please check it if you can. I don't know why this morning I didn't see the "job results", but now I do. In principle this is being done correctly, but I can't get the information of the 3 simultaneous changes of the example: ![Job_result](https://user-images.githubusercontent.com/99812647/154969314-cb08e7b1-d8fb-4e5c-8b5b-d0d9541fe99a.png) Thank you for your help!
Author
Owner

@kkthxbye-code commented on GitHub (Feb 21, 2022):

I don't know why this morning I didn't see the "job results", but now I do. In principle this is being done correctly, but I can't get the information of the 3 simultaneous changes of the example:

I don't know what that means. Three webhooks are fired as expected, each containing the changes for one of the interfaces. What data are you missing?

Edit: I maybe see what you mean. You want bulk requests to result in one single webhook containing the changes for all three seperate objects. If that is the case, that is not how the webhooks are intended to function. You could try a feature request, but I can't imagine that it would be accepted. In any case it is not a bug.

@kkthxbye-code commented on GitHub (Feb 21, 2022): >I don't know why this morning I didn't see the "job results", but now I do. In principle this is being done correctly, but I can't get the information of the 3 simultaneous changes of the example: I don't know what that means. Three webhooks are fired as expected, each containing the changes for one of the interfaces. What data are you missing? Edit: I maybe see what you mean. You want bulk requests to result in one single webhook containing the changes for all three seperate objects. If that is the case, that is not how the webhooks are intended to function. You could try a feature request, but I can't imagine that it would be accepted. In any case it is not a bug.
Author
Owner

@ane-ruiz commented on GitHub (Feb 21, 2022):

When I make the 3 changes, in the jobs, as you can see, the 3 webhooks are displayed correctly.

The problem is that of the 3, only 1 HTTP request is generated. I don't need all the changes to be made in one, but I understand that I should have the 3 requests separately. The only thing I see is that it works for the first of the 3 changes. In my case, it only runs one job in Jenkins (Ansible), it doesn't receive the other two changes. On the other hand, if I make the changes independently, if I make them very close together, Jenkins also receives them and waits to execute them because it does it in order.

@ane-ruiz commented on GitHub (Feb 21, 2022): When I make the 3 changes, in the jobs, as you can see, the 3 webhooks are displayed correctly. The problem is that of the 3, only 1 HTTP request is generated. I don't need all the changes to be made in one, but I understand that I should have the 3 requests separately. The only thing I see is that it works for the first of the 3 changes. In my case, it only runs one job in Jenkins (Ansible), it doesn't receive the other two changes. On the other hand, if I make the changes independently, if I make them very close together, Jenkins also receives them and waits to execute them because it does it in order.
Author
Owner

@kkthxbye-code commented on GitHub (Feb 21, 2022):

The problem is that of the 3, only 1 HTTP request is generated.

If you open the jobs you should be able to see HTTP response code and body content for the requests. I have a hard time imagining that only one is sent. How do you know only one is sent? Could you do a simple tcpdump/wireshark test to see if you are correct in your assumption?

@kkthxbye-code commented on GitHub (Feb 21, 2022): >The problem is that of the 3, only 1 HTTP request is generated. If you open the jobs you should be able to see HTTP response code and body content for the requests. I have a hard time imagining that only one is sent. How do you know only one is sent? Could you do a simple tcpdump/wireshark test to see if you are correct in your assumption?
Author
Owner

@jeremystretch commented on GitHub (Feb 22, 2022):

NetBox's RQ worker generates one outbounf HTTP request per webhook trigger. You can use the built-in webhook receiver to verify this.

Converting this to a discussion as it does not appear to be a bug.

@jeremystretch commented on GitHub (Feb 22, 2022): NetBox's RQ worker generates one outbounf HTTP request per webhook trigger. You can use the built-in [webhook receiver](https://netbox.readthedocs.io/en/stable/additional-features/webhooks/#troubleshooting) to verify this. Converting this to a discussion as it does not appear to be a bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6126