REST API not recognizing that a null assigned_object_id must have a null assigned_object_type #4172

Closed
opened 2025-12-29 18:33:37 +01:00 by adam · 2 comments
Owner

Originally created by @jogulin on GitHub (Oct 8, 2020).

Originally assigned to: @DanSheps on GitHub.

Environment

  • Python version: 3.6.8
  • NetBox version: 2.9.3

Steps to Reproduce

  1. curl request to update the "tags" item from an empty set to a single tag

Data (via the -d command line argument):
{"id": 1, "url": "https://netbox.example.com/api/ipam/ip-addresses/1/", "family": 4, "address": "192.168.1.1/24", "vrf": null, "status": "active", "role": null, "assigned_object_type": null, "assigned_object_id": null, "assigned_object": null, "nat_inside": null, "nat_outside": null, "dns_name": "", "description": "", "tags": [9], "custom_fields": {}, "tenant": 1}

Expected Behavior

Update to occur without issue

Observed Behavior

{"assigned_object_type": ["This field may not be null."]}

In short, if the assigned_object_id is null, the assigned_object_type must be null and the API should recognize this.

Originally created by @jogulin on GitHub (Oct 8, 2020). Originally assigned to: @DanSheps on GitHub. ### Environment * Python version: 3.6.8 * NetBox version: 2.9.3 ### Steps to Reproduce 1. curl request to update the "tags" item from an empty set to a single tag Data (via the -d command line argument): {"id": 1, "url": "https://netbox.example.com/api/ipam/ip-addresses/1/", "family": 4, "address": "192.168.1.1/24", "vrf": null, "status": "active", "role": null, "assigned_object_type": null, "assigned_object_id": null, "assigned_object": null, "nat_inside": null, "nat_outside": null, "dns_name": "", "description": "", "tags": [9], "custom_fields": {}, "tenant": 1} ### Expected Behavior Update to occur without issue ### Observed Behavior {"assigned_object_type": ["This field may not be null."]} In short, if the assigned_object_id is null, the assigned_object_type must be null and the API should recognize this.
adam added the type: bugstatus: accepted labels 2025-12-29 18:33:37 +01:00
adam closed this issue 2025-12-29 18:33:37 +01:00
Author
Owner

@jogulin commented on GitHub (Oct 8, 2020):

An alternative would be to make the assigned_object_type field mandatory, and when the assigned_object_id is null the value would be "unassigned" or something similar.

@jogulin commented on GitHub (Oct 8, 2020): An alternative would be to make the assigned_object_type field mandatory, and when the assigned_object_id is null the value would be "unassigned" or something similar.
Author
Owner

@DanSheps commented on GitHub (Oct 8, 2020):

Looks like a simple allow_null=True in the serializer should fix this, I will tackle it after lunch

@DanSheps commented on GitHub (Oct 8, 2020): Looks like a simple `allow_null=True` in the serializer should fix this, I will tackle it after lunch
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4172