Include "private" fields when serializing objects for change logging #16290
Labels
complexity: low
Requires minimal effort to implement
status: accepted
This issue has been accepted for implementation
type: feature
Introduction of new functionality to the application
NetBox version
v4.0.3
Feature type
Change to existing functionality
Proposed functionality
When logging the creation, change, or deletion of an object, NetBox serializes the Python instance using the
serialize_object()
utility function. This wraps Django's internal serialization function, with some caveats. First, we ignore MPTT internal fields:netbox/netbox/utilities/serialization.py
Lines 33 to 36 in 103c08c
Second, we omit any "private" fields; those which begin with an underscore. (This is done purely as a means of noise reduction, and not in the interest of privacy or security.)
netbox/netbox/utilities/serialization.py
Lines 48 to 51 in 103c08c
This issue proposes that we stop omitting these fields from the serialized data. Where it makes sense to omit these fields from display (e.g. when rendering a diff in the change log), the fields can be omitted from the output.
Use case
The exclusion of MPTT internal fields poses an issue for the staged changes API, which has been captured in #13422.
The omission of certain private fields can pose similar problems. For instance, omitting the
_name
field when serializing a site fails to capture the naturalized form of the site's name. When attempting to restore a site from serialized data usingdeserialize_object()
, the resulting instance will be saved to the database with an empty value for_name
, leading to issues with query ordering.Database changes
None
External dependencies
None
The text was updated successfully, but these errors were encountered: