Description
Deployment Type
Self-hosted
NetBox Version
4.2.2
Python Version
3.11
Steps to Reproduce
I am trying to associate a VM interface to a prefix via custom field, using Pynetbox
new_prefix.custom_fields['workflow_associated_prefix_to_interface_mapping'] = nb_interface.id
new_prefix.save()
This is the custom field
If I comment out the custom_field statement, save is fine. I also tried saving via UI with the relationship, UI worked fine.
Expected Behavior
Saving works.
Observed Behavior
And I got this error
pynetbox.core.query.RequestError: The request failed with code 500 Internal Server Error: {'error': "'VMInterface' object has no attribute 'get'", 'exception': 'AttributeError', 'netbox_version': '4.2.2', 'python_version': '3.11.2'}
It appears this is the line that threw the error:

def validate(self, data):
# Validate many-to-many VLAN assignments
virtual_machine = self.instance.virtual_machine if self.instance else data.get('virtual_machine') <-----
for vlan in data.get('tagged_vlans', []):
if vlan.site not in [virtual_machine.site, None]:
raise serializers.ValidationError({
'tagged_vlans': f"VLAN {vlan} must belong to the same site as the interface's parent virtual "
f"machine, or it must be global."
})
Somehow... data is already a VMInterface object