Mac address can not be unset via API #7971

Closed
opened 2025-12-29 20:30:37 +01:00 by adam · 0 comments
Owner

Originally created by @amhn on GitHub (May 1, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.5.0

Python version

3.11

Steps to Reproduce

  1. Create VM Interface with mac address set
  2. Try removing the mac address with null:
curl \
-H "Authorization: Token $NETBOX_TOKEN" \
-H "Content-type: application/json" \
$NETBOX_SCHEME://$NETBOX_URL/api/virtualization/interfaces/4/ \
-X PATCH \
--data '{"mac_address": null}'
  1. Try removing the mac address with empty string:
curl \
-H "Authorization: Token $NETBOX_TOKEN" \
-H "Content-type: application/json" \
$NETBOX_SCHEME://$NETBOX_URL/api/virtualization/interfaces/4/ \
-X PATCH \
--data '{"mac_address": ""}'

Expected Behavior

Mac address can be set back to NULL via API

Observed Behavior

With step 2 the error message is {"mac_address":["This field may not be null."]}. With step 3 it is {"mac_address":["This field may not be blank."]}

Probably allow_null = True should be added to the mac_address field of the VMInterfaceSerializer (and InterfaceSerializer for device interfaces)

Originally created by @amhn on GitHub (May 1, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.5.0 ### Python version 3.11 ### Steps to Reproduce 1. Create VM Interface with mac address set 2. Try removing the mac address with null: ```bash curl \ -H "Authorization: Token $NETBOX_TOKEN" \ -H "Content-type: application/json" \ $NETBOX_SCHEME://$NETBOX_URL/api/virtualization/interfaces/4/ \ -X PATCH \ --data '{"mac_address": null}' ``` 3. Try removing the mac address with empty string: ```bash curl \ -H "Authorization: Token $NETBOX_TOKEN" \ -H "Content-type: application/json" \ $NETBOX_SCHEME://$NETBOX_URL/api/virtualization/interfaces/4/ \ -X PATCH \ --data '{"mac_address": ""}' ``` ### Expected Behavior Mac address can be set back to NULL via API ### Observed Behavior With step 2 the error message is `{"mac_address":["This field may not be null."]}`. With step 3 it is `{"mac_address":["This field may not be blank."]}` Probably `allow_null = True` should be added to the mac_address field of the VMInterfaceSerializer (and InterfaceSerializer for device interfaces)
adam added the type: bugstatus: accepted labels 2025-12-29 20:30:37 +01:00
adam closed this issue 2025-12-29 20:30:38 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7971