netbox
netbox copied to clipboard
CustomField MultiObject returns dict but expects id's
NetBox version
v3.2.9
Python version
3.9
Steps to Reproduce
- Create a custom field of the multiobject type
- create a device that uses that custom field and populate with some data
- retrieve the custom field through the API
- update the custom field with a new ID
- save the device
Expected Behavior
The device with customs fields is updated with the new value's
Observed Behavior
The save of the object fails with the message that a dict is not acceptable, only ID's are allowed
This is because
- the GET API returns the multiobject custom fields as an array of dicts.
- the POST API expects only ID's and not dicts
Reason: API GET call returns the expanded dicts for custom_fields multiobjects when adding a new object to the custom_fields, we use the ID of the object This causes the custom_fields to be a mix of dict and id's But the deserializer of the CustomField class expects only ID's
Created a PR
pynetbox is affected by this too : https://github.com/netbox-community/pynetbox/issues/501
when doing an .updates() on an object with a customfield of Object/Multiobject, it always returns true. the API is sending the full dict, while only accepting an id. the compare is then done between an array_of_dict and an array_of_int, which is ofcourse always different
I think it needs to be decided if that API will send/accept dicts only or ids only