Skip to content

Unable to nullify choice fields via the API #4083

Closed
@fantasmita

Description

@fantasmita

Environment

  • Python version: 3.6.5
  • NetBox version: 2.7.3

To fully unrack a device, you must blank out its rack, position, and face values.
The face field has a non-null constraint and has an API validator that requires its value to be either front or rear, so it's not possible to blank out the value through the API which prevents the device from being removed from the rack.

Steps to Reproduce

  1. Create a device in netbox with values for rack, position, and face.
  2. Try to clear all three values with a PATCH like the following
curl -X PATCH "https://$NETBOX/api/dcim/devices/$ID/" -H  "accept: application/json" -H  "Content-Type: application/json" -H  "X-CSRFToken: $TOKEN" -d "{  \"rack\": null,  \"position\": null,  \"face\": \"\"}"

Expected Behavior

The device to be unracked

Observed Behavior

{
  "face": [
    " is not a valid choice."
  ]
}

If passing null for the face value, the django non-null constraint is hit.
If patching just the rack and position values without touching the face, the Cannot select a rack face without assigning a rack. validator is hit.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions