REST API - can't change mode of tagged Interface to "access" or null #11539

Closed
opened 2025-12-29 21:46:33 +01:00 by adam · 3 comments
Owner

Originally created by @ed-ud on GitHub (Aug 28, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.3.5

Python Version

3.12

Steps to Reproduce

  1. Create an Interface oobject.
  2. Change 802.1q mode tagged and assign VLANs.
  3. Do a REST API PATCH request to set mode to "access" or null:

PATCH on /dcim/interfaces/12345/
{
"mode": null
}

Expected Behavior

Interface mode should be changed and Tagged VLANs should be removed.

Observed Behavior

ERROR:
{
"tagged_vlans": [
"Interface mode does not support tagged vlans"
]
}

Originally created by @ed-ud on GitHub (Aug 28, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.3.5 ### Python Version 3.12 ### Steps to Reproduce 1. Create an Interface oobject. 2. Change 802.1q mode tagged and assign VLANs. 3. Do a REST API PATCH request to set mode to "access" or null: PATCH on /dcim/interfaces/12345/ { "mode": null } ### Expected Behavior Interface mode should be changed and Tagged VLANs should be removed. ### Observed Behavior ERROR: { "tagged_vlans": [ "Interface mode does not support tagged vlans" ] }
adam added the type: bug label 2025-12-29 21:46:33 +01:00
adam closed this issue 2025-12-29 21:46:34 +01:00
Author
Owner

@jnovinger commented on GitHub (Aug 28, 2025):

This appears to be working as designed. This validation was explicitly added in commit 63a167f13 (February 2025) to fix issue #15924, where the REST API was incorrectly allowing invalid VLAN assignments on interfaces.

The current strict validation is intentional - it prevents the API from accepting invalid state combinations and requires users to be explicit about their intended changes. This approach ensures data integrity and prevents accidental data loss.

Workaround: Include both changes in your PATCH request:

{
  "mode": null,
  "tagged_vlans": []
}
@jnovinger commented on GitHub (Aug 28, 2025): This appears to be working as designed. This validation was explicitly added in commit 63a167f13 (February 2025) to fix issue #15924, where the REST API was incorrectly allowing invalid VLAN assignments on interfaces. The current strict validation is intentional - it prevents the API from accepting invalid state combinations and requires users to be explicit about their intended changes. This approach ensures data integrity and prevents accidental data loss. **Workaround**: Include both changes in your PATCH request: ```json { "mode": null, "tagged_vlans": [] }
Author
Owner

@ed-ud commented on GitHub (Aug 28, 2025):

The "tagged_vlans" field is not relevant when the Interface mode is set to "access" or null (or "tagged-all" for that matter).
It maybe makes sense to enforce that the user delete all tagged_vlans when changing the mode
in the UI but it doesn't really makes sense to include a value for tagged_vlans in a REST API PATCH request
when the mode is not set to "tagged" on the Interface or set to "tagged" in the request itself.

But that's just my 2 cents FWIW.

@ed-ud commented on GitHub (Aug 28, 2025): The "tagged_vlans" field is not relevant when the Interface mode is set to "access" or null (or "tagged-all" for that matter). It maybe makes sense to enforce that the user delete all tagged_vlans when changing the mode in the UI but it doesn't really makes sense to include a value for tagged_vlans in a REST API PATCH request when the mode is not set to "tagged" on the Interface or set to "tagged" in the request itself. But that's just my 2 cents FWIW.
Author
Owner

@ed-ud commented on GitHub (Aug 28, 2025):

Some may argue that it's perfectly okay to have a list of tagged_vlans stored on the Interface even when the mode is set to something other than "tagged", perhaps when setting up an Interface but not wanting it to be operational as a trunk yet.

@ed-ud commented on GitHub (Aug 28, 2025): Some may argue that it's perfectly okay to have a list of tagged_vlans stored on the Interface even when the mode is set to something other than "tagged", perhaps when setting up an Interface but not wanting it to be operational as a trunk yet.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11539