[PR #14477] [MERGED] 14147 Prevent logging to Change Log when no changes are made #14396

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/14477
Author: @arthanson
Created: 12/8/2023
Status: Merged
Merged: 12/15/2023
Merged by: @jeremystretch

Base: featureHead: 14147-no-changelog


📝 Commits (6)

  • f6f1fa7 14147 Prevent logging to Change Log when no changes are made
  • 6823251 14147 add test
  • c0e6f61 14147 add exclude_fields to serialize_object
  • 30eb48b 14147 make skip empty default to True
  • 033b10b 14147 remove override of to_objectchange
  • 7d20484 Misc cleanup

📊 Changes

7 files changed (+112 additions, -14 deletions)

View changed files

📝 docs/configuration/miscellaneous.md (+11 -0)
📝 netbox/extras/models/change_logging.py (+4 -0)
📝 netbox/extras/signals.py (+4 -3)
📝 netbox/extras/tests/test_changelog.py (+61 -0)
📝 netbox/netbox/models/features.py (+17 -4)
📝 netbox/netbox/settings.py (+1 -0)
📝 netbox/utilities/utils.py (+14 -7)

📄 Description

Fixes: #14147

Prevents an ObjectChange record from being created if there is an update and no data has changed.

Adds a CHANGELOG_SKIP_EMPTY_CHANGES config param, default False, that allows to skip the logging if no changes. i.e. the default is the old behavior.

If this flag is set, then to_objectchange can return None which needs to be checked in overriden functions. Did it this way for performance to prevent instantiating an object and serializing data if it is never going to be used.

A side-effect of this change, which should probably be default, is the last_updated field is removed from the serialized data of the changelog. The reason for this is this would be counted as a changed field when comparing the serialized records (pre / post update).

Added to feature branch as it seems a big enough feature change to be in a point release.


🔄 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/14477 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 12/8/2023 **Status:** ✅ Merged **Merged:** 12/15/2023 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `14147-no-changelog` --- ### 📝 Commits (6) - [`f6f1fa7`](https://github.com/netbox-community/netbox/commit/f6f1fa799e7eab91f9ffabfe229f061e966bcb70) 14147 Prevent logging to Change Log when no changes are made - [`6823251`](https://github.com/netbox-community/netbox/commit/68232511a07013d93626115cf2eb7975a29e6eda) 14147 add test - [`c0e6f61`](https://github.com/netbox-community/netbox/commit/c0e6f6172f4813d5d6766c2ca8f02b663a4322c0) 14147 add exclude_fields to serialize_object - [`30eb48b`](https://github.com/netbox-community/netbox/commit/30eb48b580ed26c8c4971ab39abcbd37160b95b4) 14147 make skip empty default to True - [`033b10b`](https://github.com/netbox-community/netbox/commit/033b10b951e9af08a32234f92d5a974feb949a9c) 14147 remove override of to_objectchange - [`7d20484`](https://github.com/netbox-community/netbox/commit/7d20484220da0720ae6424632a11c5da095715f9) Misc cleanup ### 📊 Changes **7 files changed** (+112 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `docs/configuration/miscellaneous.md` (+11 -0) 📝 `netbox/extras/models/change_logging.py` (+4 -0) 📝 `netbox/extras/signals.py` (+4 -3) 📝 `netbox/extras/tests/test_changelog.py` (+61 -0) 📝 `netbox/netbox/models/features.py` (+17 -4) 📝 `netbox/netbox/settings.py` (+1 -0) 📝 `netbox/utilities/utils.py` (+14 -7) </details> ### 📄 Description ### Fixes: #14147 Prevents an ObjectChange record from being created if there is an update and no data has changed. Adds a CHANGELOG_SKIP_EMPTY_CHANGES config param, default False, that allows to skip the logging if no changes. i.e. the default is the old behavior. If this flag is set, then to_objectchange can return None which needs to be checked in overriden functions. Did it this way for performance to prevent instantiating an object and serializing data if it is never going to be used. A side-effect of this change, which should probably be default, is the `last_updated` field is removed from the serialized data of the changelog. The reason for this is this would be counted as a changed field when comparing the serialized records (pre / post update). Added to feature branch as it seems a big enough feature change to be in a point release. --- <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:24:14 +01:00
adam closed this issue 2025-12-29 23:24:15 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14396