[PR #3632] [MERGED] Rewrite change logging middleware #12602

Closed
opened 2025-12-29 22:22:35 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/3632
Author: @jeremystretch
Created: 10/22/2019
Status: Merged
Merged: 10/25/2019
Merged by: @jeremystretch

Base: developHead: 3309-changelog-middleware


📝 Commits (2)

  • ccb9f7b Rewrote ObjectChangeMiddleware to remove the curried handle_deleted_object() function
  • 0ebc2e4 Fix reporting of custom fields in webhook data on object deletion

📊 Changes

6 files changed (+125 additions, -60 deletions)

View changed files

📝 netbox/extras/api/customfields.py (+6 -6)
📝 netbox/extras/middleware.py (+46 -38)
📝 netbox/extras/models.py (+9 -4)
📝 netbox/extras/tests/test_changelog.py (+54 -11)
netbox/utilities/querysets.py (+9 -0)
📝 netbox/utilities/utils.py (+1 -1)

📄 Description

Fixes: #3309

(I hope)

This PR represents a major overhaul of ObjectChangeMiddleware. The handle_deleted_object signal handler is no longer curried prior to the response being processed, which I believe was responsible for the root issue documented in #3309. Instead of attempting to pass the current request and immediately acting on deleted objects, we now make a copy of the object being deleted and defer processing to until after the request has been completed. This should ensure that the request user has been resolved by the time the change is recorded.

Some changes to custom field processing were also necessary to ensure that the current custom field values are recorded during any change scenario. I've also extended the change logging tests to validate tags and custom fields.


🔄 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/3632 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 10/22/2019 **Status:** ✅ Merged **Merged:** 10/25/2019 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `3309-changelog-middleware` --- ### 📝 Commits (2) - [`ccb9f7b`](https://github.com/netbox-community/netbox/commit/ccb9f7bfe221d37f93d3dc0a315d244f81d27ccd) Rewrote ObjectChangeMiddleware to remove the curried handle_deleted_object() function - [`0ebc2e4`](https://github.com/netbox-community/netbox/commit/0ebc2e4ac0e43578de482e42dd7a95c2f552abfc) Fix reporting of custom fields in webhook data on object deletion ### 📊 Changes **6 files changed** (+125 additions, -60 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/api/customfields.py` (+6 -6) 📝 `netbox/extras/middleware.py` (+46 -38) 📝 `netbox/extras/models.py` (+9 -4) 📝 `netbox/extras/tests/test_changelog.py` (+54 -11) ➕ `netbox/utilities/querysets.py` (+9 -0) 📝 `netbox/utilities/utils.py` (+1 -1) </details> ### 📄 Description ### Fixes: #3309 (I hope) This PR represents a major overhaul of `ObjectChangeMiddleware`. The `handle_deleted_object` signal handler is no longer curried prior to the response being processed, which I believe was responsible for the root issue documented in #3309. Instead of attempting to pass the current request and immediately acting on deleted objects, we now make a copy of the object being deleted and defer processing to until after the request has been completed. This should ensure that the request user has been resolved by the time the change is recorded. Some changes to custom field processing were also necessary to ensure that the current custom field values are recorded during any change scenario. I've also extended the change logging tests to validate tags and custom fields. --- <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 22:22:35 +01:00
adam closed this issue 2025-12-29 22:22:35 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12602