Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook sends multiple requests when updating tags #6284

Closed
nahun opened this issue Apr 27, 2021 · 1 comment · Fixed by #6516
Closed

Webhook sends multiple requests when updating tags #6284

nahun opened this issue Apr 27, 2021 · 1 comment · Fixed by #6516
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@nahun
Copy link

nahun commented Apr 27, 2021

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.

@nahun nahun added the type: bug A confirmed report of unexpected behavior in the application label Apr 27, 2021
@jeremystretch
Copy link
Member

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 jeremystretch added the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Apr 27, 2021
@jeremystretch jeremystretch self-assigned this May 18, 2021
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels May 18, 2021
jeremystretch added a commit that referenced this issue May 28, 2021
jeremystretch added a commit that referenced this issue Jun 1, 2021
jeremystretch added a commit that referenced this issue Jun 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants