-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Copy link
Labels
severity: mediumResults in substantial degraded or broken functionality for specfic workflowsResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Milestone
Description
Deployment Type
NetBox Cloud
NetBox Version
v4.2.5
Python Version
3.10
Steps to Reproduce
- Create an object with one or more tags assigned. (In this example, we use a tenant.)
- Serialize the object using the
serialize_object()utility function.
from pprint import pprint
from tenancy.models import Tenant
from utilities.serialization import serialize_object, deserialize_object
tenant = Tenant.objects.first()
data = serialize_object(tenant)
pprint(data)The output data is below:
{'comments': '',
'created': '2020-12-19T00:00:00Z',
'custom_fields': {'cust_id': 'CYB01'},
'description': '',
'group': 1,
'last_updated': '2025-03-12T18:02:59.743Z',
'name': 'Cyberdyne Systems',
'slug': 'cyberdyne',
'tags': ['Alpha', 'Bravo', 'Charlie']}- Attempt to deserialize the serialized data back into the object.
deserialize_object(Tenant, data)Expected Behavior
deserialize_object() should return the deserialized object with all attributes set correctly.
Observed Behavior
A DeserializationError is raised:
django.core.serializers.base.DeserializationError: ['“Alpha” value must be an integer.']: (tenancy.tenant:pk=None) field_value was 'Alpha'
This occurs because the function does not account for the tags being specified by name rather than by numeric primary key.
Metadata
Metadata
Assignees
Labels
severity: mediumResults in substantial degraded or broken functionality for specfic workflowsResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application