Inconsistent role requirement on virtual machine between API and WebUI #3327

Closed
opened 2025-12-29 18:27:44 +01:00 by adam · 1 comment
Owner

Originally created by @netsandbox on GitHub (Feb 14, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.6.9
  • NetBox version: 2.7.6

Steps to Reproduce

  1. create virtual machine by API: role is not required
  2. create virtual machine in WebUI: role is required

Expected Behavior

If a role for a virtual machine is required or not should be the same for API and WebUI.

Observed Behavior

If you create a virtual machine by API, role isn't required.
If you create a virtual machine in the WebUI, role is required.

The VirtualMachine model defines blank=Trueand null=True, which makes role not required by API:
https://github.com/netbox-community/netbox/blob/v2.7.6/netbox/virtualization/models.py#L212-L219

The VirtualMachineForm doesn't have a required=False for role, which makes role required in the WebUI:
https://github.com/netbox-community/netbox/blob/v2.7.6/netbox/virtualization/forms.py#L352-L360

Originally created by @netsandbox on GitHub (Feb 14, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: 3.6.9 * NetBox version: 2.7.6 ### Steps to Reproduce 1. create virtual machine by API: role is not required 2. create virtual machine in WebUI: role is required ### Expected Behavior If a role for a virtual machine is required or not should be the same for API and WebUI. ### Observed Behavior If you create a virtual machine by API, role isn't required. If you create a virtual machine in the WebUI, role is required. The VirtualMachine model defines `blank=True`and `null=True`, which makes role not required by API: https://github.com/netbox-community/netbox/blob/v2.7.6/netbox/virtualization/models.py#L212-L219 The VirtualMachineForm doesn't have a `required=False` for role, which makes role required in the WebUI: https://github.com/netbox-community/netbox/blob/v2.7.6/netbox/virtualization/forms.py#L352-L360
adam added the type: bugstatus: accepted labels 2025-12-29 18:27:44 +01:00
adam closed this issue 2025-12-29 18:27:45 +01:00
Author
Owner

@hSaria commented on GitHub (Feb 14, 2020):

You're correct. This happened during some internal housekeeping (#3912). The solution would be to add required=False as you described.

@hSaria commented on GitHub (Feb 14, 2020): You're correct. This happened during some internal housekeeping (#3912). The solution would be to add `required=False` as you described.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3327