Parent group is required attribute on contact group object when using REST API #5765

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

Originally created by @rodvand on GitHub (Dec 12, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.1.0

Python version

3.8

Steps to Reproduce

curl -X POST \
-H "Authorization: Token TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
https://NETBOX_URL/api/tenancy/contact-groups/ \
--data '{
    "name": "Test Contact Group",
    "slug": "contact-group-slug" }'

Expected Behavior

A contact group is created.

Observed Behavior

{
    "parent": [
        "This field is required."
    ]
}

I reported a similar issue when creating a Contact object - https://github.com/netbox-community/netbox/issues/7771

In the API docs the parent is required, but nullable. I guess it is automatically set to null when using the Web UI. It would be handy if it defaults to null using the API to avoid having to explicitly set it to null when making requests.

Originally created by @rodvand on GitHub (Dec 12, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.1.0 ### Python version 3.8 ### Steps to Reproduce ``` curl -X POST \ -H "Authorization: Token TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ https://NETBOX_URL/api/tenancy/contact-groups/ \ --data '{ "name": "Test Contact Group", "slug": "contact-group-slug" }' ``` ### Expected Behavior A contact group is created. ### Observed Behavior ``` { "parent": [ "This field is required." ] } ``` I reported a similar issue when creating a Contact object - https://github.com/netbox-community/netbox/issues/7771 In the API docs the `parent` is required, but nullable. I guess it is automatically set to null when using the Web UI. It would be handy if it defaults to null using the API to avoid having to explicitly set it to null when making requests.
adam added the type: bugstatus: accepted labels 2025-12-29 19:32:23 +01:00
adam closed this issue 2025-12-29 19:32:24 +01:00
Author
Owner

@rodvand commented on GitHub (Dec 12, 2021):

I also noticed that neither the name or slug is required to be unique. I am not sure if this is intentional, but I could see it lead to confusion when it's impossible to separate two (or more) groups with the same name.

@rodvand commented on GitHub (Dec 12, 2021): I also noticed that neither the name or slug is required to be unique. I am not sure if this is intentional, but I could see it lead to confusion when it's impossible to separate two (or more) groups with the same name.
Author
Owner

@jeremystretch commented on GitHub (Dec 13, 2021):

The serializer thinks the field is required because the parent field is referenced for unique enforcement. We've run into this with a number of other models as well. It might be something worth calling out upstream in DRF, but for now setting a default null value for the parent field on the serializer resolves this.

I also noticed that neither the name or slug is required to be unique.

Contact group names are required to be unique only within a parent group.

@jeremystretch commented on GitHub (Dec 13, 2021): The serializer thinks the field is required because the parent field is referenced for unique enforcement. We've run into this with a number of other models as well. It might be something worth calling out upstream in DRF, but for now setting a default null value for the `parent` field on the serializer resolves this. > I also noticed that neither the name or slug is required to be unique. Contact group names are required to be unique only within a parent group.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5765