[PR #15318] [CLOSED] Fixes: #15194 - Check the whole queue for matching queued webhooks #14572

Closed
opened 2025-12-29 23:25:16 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/15318
Author: @peteeckel
Created: 2/29/2024
Status: Closed

Base: developHead: 15194-fix-duplicate-webhook-invocations


📝 Commits (6)

  • b5cb67b Fixes: #15194 - Check the whole queue for matching queued webhooks
  • 9f3c750 HACK: Make get_serializer_for_model() work with dummy_plugin
  • 8fd5085 Correct the name of the serializer for DummyModel
  • e512027 Modified DummyModel to make it trigger event rules
  • ecdd307 Added essential tests for the double event rule invocation problem
  • 773b6e4 PEP8 fixes

📊 Changes

7 files changed (+82 additions, -18 deletions)

View changed files

📝 netbox/extras/signals.py (+17 -12)
📝 netbox/extras/tests/test_event_rules.py (+46 -1)
📝 netbox/netbox/tests/dummy_plugin/api/serializers.py (+1 -1)
📝 netbox/netbox/tests/dummy_plugin/api/views.py (+2 -2)
📝 netbox/netbox/tests/dummy_plugin/migrations/0001_initial.py (+2 -0)
📝 netbox/netbox/tests/dummy_plugin/models.py (+8 -1)
📝 netbox/utilities/api.py (+6 -1)

📄 Description

Fixes: #15194

This PR changes the logic how changes to M2M relationships are matched to changes in the base object to which the M2M relationship is related. The current code assumes that the post_save is immediately followed by the m2m_changed signal for the former, but that is not generally true as any save() operation for a different object occurring in between will separate the two entries in the queue. This results in two webhooks being triggered, the first one of which has incorrect data in its payload.

The new code finds the position of the webhook data for the object change in the queue and updates it with the M2M change data and ensures only one webhook is triggered, and with the correct data.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/15318 **Author:** [@peteeckel](https://github.com/peteeckel) **Created:** 2/29/2024 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `15194-fix-duplicate-webhook-invocations` --- ### 📝 Commits (6) - [`b5cb67b`](https://github.com/netbox-community/netbox/commit/b5cb67bdbd67599c7d300c5a20faabb30fb1286b) Fixes: #15194 - Check the whole queue for matching queued webhooks - [`9f3c750`](https://github.com/netbox-community/netbox/commit/9f3c750786b99aa1c95bde094cb861588785f1e3) HACK: Make get_serializer_for_model() work with dummy_plugin - [`8fd5085`](https://github.com/netbox-community/netbox/commit/8fd508560d99a97f3c67455b31b9cff2fa1a82ca) Correct the name of the serializer for DummyModel - [`e512027`](https://github.com/netbox-community/netbox/commit/e512027a91d4e5ed133f1c4011102ec0b416026f) Modified DummyModel to make it trigger event rules - [`ecdd307`](https://github.com/netbox-community/netbox/commit/ecdd30778a9ef6f6fbcf31dd356dceec21203756) Added essential tests for the double event rule invocation problem - [`773b6e4`](https://github.com/netbox-community/netbox/commit/773b6e413070c9909fc9cd3885fc07af166e1690) PEP8 fixes ### 📊 Changes **7 files changed** (+82 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/signals.py` (+17 -12) 📝 `netbox/extras/tests/test_event_rules.py` (+46 -1) 📝 `netbox/netbox/tests/dummy_plugin/api/serializers.py` (+1 -1) 📝 `netbox/netbox/tests/dummy_plugin/api/views.py` (+2 -2) 📝 `netbox/netbox/tests/dummy_plugin/migrations/0001_initial.py` (+2 -0) 📝 `netbox/netbox/tests/dummy_plugin/models.py` (+8 -1) 📝 `netbox/utilities/api.py` (+6 -1) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #15194 <!-- Please include a summary of the proposed changes below. --> This PR changes the logic how changes to M2M relationships are matched to changes in the base object to which the M2M relationship is related. The current code assumes that the `post_save` is immediately followed by the `m2m_changed` signal for the former, but that is not generally true as any `save()` operation for a different object occurring in between will separate the two entries in the queue. This results in two webhooks being triggered, the first one of which has incorrect data in its payload. The new code finds the position of the webhook data for the object change in the queue and updates it with the M2M change data and ensures only one webhook is triggered, and with the correct data. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 23:25:16 +01:00
adam closed this issue 2025-12-29 23:25:16 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14572