CustomField MultiObject returns dict but expects id's #6924

Closed
opened 2025-12-29 19:46:46 +01:00 by adam · 2 comments
Owner

Originally created by @PieterL75 on GitHub (Sep 1, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.2.9

Python version

3.9

Steps to Reproduce

  1. Create a custom field of the multiobject type
  2. create a device that uses that custom field and populate with some data
  3. retrieve the custom field through the API
  4. update the custom field with a new ID
  5. 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

Originally created by @PieterL75 on GitHub (Sep 1, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.2.9 ### Python version 3.9 ### Steps to Reproduce 1. Create a custom field of the multiobject type 2. create a device that uses that custom field and populate with some data 3. retrieve the custom field through the API 4. update the custom field with a new ID 5. 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
adam added the type: bugstatus: accepted labels 2025-12-29 19:46:46 +01:00
adam closed this issue 2025-12-29 19:46:47 +01:00
Author
Owner

@PieterL75 commented on GitHub (Sep 27, 2022):

Created a PR

@PieterL75 commented on GitHub (Sep 27, 2022): Created a PR
Author
Owner

@PieterL75 commented on GitHub (Oct 13, 2022):

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

@PieterL75 commented on GitHub (Oct 13, 2022): 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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6924