netbox-community / pynetbox

Python API client library for Netbox.
Apache License 2.0
538 stars 165 forks source link

List of dictionaries as a field causes Record.save() error #625

Open MaayanPeleg opened 1 week ago

MaayanPeleg commented 1 week ago

pynetbox version

v7.3.3

NetBox version

V3.7.8

Python version

3.9

Steps to Reproduce

In a plugin model, create a JSON field that is set to a lost of dictionaries. For example: [{"example": "bug"}]

Expected Behavior

This field should be handles as a JSON list

Observed Behavior

Pynetbox on initialising the record from netbox, treats the list of dictionaries as references to objects in netbox, so each dictionary is initialised as records, when save is ran, it trys to get it's records id and raises an error as there is no id, as it's not a Record. The bug appears to be caused in _init_cache aswell as in _parse_values() in list_parser()