pynetbox icon indicating copy to clipboard operation
pynetbox copied to clipboard

ObjectChanges moved to core module in netbox 4.1

Open Urth opened this issue 6 months ago • 0 comments

pynetbox version

7.5.0

NetBox version

4.2.9

Python version

3.12

Steps to Reproduce

from pynetbox import api
from pynetbox.models.extras import ObjectChanges
nb = api(netbox_url, token=netbox_token)
change = next(nb.core.object_changes.filter(limit=1), None)
assert isinstance(change, ObjectChanges), type(change)

On >netbox-4.1 the ObjectChanges model is not used and this causes the object_data, postchange_data and prechange_data to be processed as Records. As a result simple truthiness checks if change.postchange_data: always yields True because bool(Record({}, None, None)) is True which is unexpected.

Expected Behavior

nb.core.object_changes should return ObjectChanges instances.

Observed Behavior

nb.core.object_changes returns Record instances.

Urth avatar Jul 10 '25 14:07 Urth