400 error on dcim/device-types: subdevice_role "This field may not be null" #1872

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

Originally created by @aruhier on GitHub (Jul 25, 2018).

Issue type

[ ] Feature request
[x] Bug report
[ ] Documentation
[ ] Housekeeping

Environment

  • Python version: 3.6
  • NetBox version: at least 2.3.3 to e82bf66a76

Description

  • Create or update a device type through the API by setting subdevice_role to null.
  • You should get a 400 error, containing this message: {"subdevice_role":["This field may not be null."]}

I tried to force the attribute as non required in its serializer, but it apparently didn't fix the issue.

Thanks!

Originally created by @aruhier on GitHub (Jul 25, 2018). ### Issue type [ ] Feature request <!-- An enhancement of existing functionality --> [x] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> [ ] Housekeeping <!-- Changes pertaining to the codebase itself --> ### Environment * Python version: 3.6 * NetBox version: at least 2.3.3 to e82bf66a766d77 ### Description - Create or update a device type through the API by setting `subdevice_role` to `null`. - You should get a 400 error, containing this message: `{"subdevice_role":["This field may not be null."]}` I tried to force the attribute as non required in its serializer, but it apparently didn't fix the issue. Thanks!
adam added the type: bugstatus: accepted labels 2025-12-29 17:19:56 +01:00
adam closed this issue 2025-12-29 17:19:56 +01:00
Author
Owner

@aruhier commented on GitHub (Jul 25, 2018):

I debugged a bit, and it seems that allow_null is set to False for the ChoiceFieldSerializer here. Forcing it to True fixes the issue.

@aruhier commented on GitHub (Jul 25, 2018): I debugged a bit, and it seems that `allow_null` is set to `False` for the `ChoiceFieldSerializer` [here](https://github.com/digitalocean/netbox/blob/develop/netbox/dcim/api/serializers.py#L286). Forcing it to `True` fixes the issue.
Author
Owner

@aruhier commented on GitHub (Jul 31, 2018):

Thanks a lot!

@aruhier commented on GitHub (Jul 31, 2018): Thanks a lot!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1872