Webhook sends multiple requests when updating tags #4828

Closed
opened 2025-12-29 19:21:01 +01:00 by adam · 1 comment
Owner

Originally created by @nahun on GitHub (Apr 27, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.11.1

Python version

3.8

Steps to Reproduce

  1. Create webhook for DCIM->Interface (or any model I found so far)
  2. Check all event types
  3. URL: http://localhost:9000/
  4. HTTP method: POST
  5. HTTP content type: application/json
  6. Uncheck SSL verification
  7. Start the webhook receiver: python netbox/manage.py webhook_receiver
  8. Add or remove tags from an existing interface or create a new interface with tags defined

Expected Behavior

One HTTP request sent to the webhook receiver.

Observed Behavior

The webhook receiver will show multiple HTTP requests for a single interface being updated.

Originally created by @nahun on GitHub (Apr 27, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.11.1 ### Python version 3.8 ### Steps to Reproduce 1. Create webhook for DCIM->Interface (or any model I found so far) 2. Check all event types 3. URL: http://localhost:9000/ 4. HTTP method: POST 5. HTTP content type: application/json 6. Uncheck SSL verification 7. Start the webhook receiver: `python netbox/manage.py webhook_receiver` 8. Add or remove tags from an existing interface or create a new interface with tags defined ### Expected Behavior One HTTP request sent to the webhook receiver. ### Observed Behavior The webhook receiver will show multiple HTTP requests for a single interface being updated.
adam added the type: bugstatus: accepted labels 2025-12-29 19:21:01 +01:00
adam closed this issue 2025-12-29 19:21:01 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 27, 2021):

This happens due the way objects are saved in the database. When you create or update an object with tags assigned, two things happen:

  1. The row is created/saved in its table and the post_save signal is fired, triggering a webhook.
  2. Tag assignments to the object are created in the database and the m2m_changed signal is fired, triggering a second webhook.

You'll notice that the first webhook doesn't specify any tags assigned to the object, whereas the second one does.

We can probably devise a way to avoid firing two webhooks, however it will likely require delaying the queuing of webhooks until the request has been processed.

@jeremystretch commented on GitHub (Apr 27, 2021): This happens due the way objects are saved in the database. When you create or update an object with tags assigned, two things happen: 1. The row is created/saved in its table and the `post_save` signal is fired, triggering a webhook. 2. Tag assignments to the object are created in the database and the `m2m_changed` signal is fired, triggering a second webhook. You'll notice that the first webhook doesn't specify any tags assigned to the object, whereas the second one does. We can probably devise a way to avoid firing two webhooks, however it will likely require delaying the queuing of webhooks until the request has been processed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4828