Changing scope of VLAN group breaks possible VLAN association #10797

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

Originally created by @bb-Ricardo on GitHub (Feb 22, 2025).

Originally assigned to: @arthanson on GitHub.

Deployment Type

NetBox Cloud

NetBox Version

v4.2.2

Python Version

3.12

Steps to Reproduce

  1. create a Site "New York"
  2. create as Site Group "USA"
  3. assign site "New York" to Site Group "USA"
  4. create a VLAN group "example group" with scope Site and and site "New York"
  5. create a VLAN "example VLAN" and assign both site "New York" and and group "example group"
  6. change scope of VLAN group "example group" to Site-Group and select group "USA"
  7. try to create a new VLAN "example with issue" and assign both site "New York" and and group "example group"

Expected Behavior

That the VLAN "example with issue" can be assigned to VLAN group "example group" and site "New York" at the same time.

Observed Behavior

Step 7 will fail, even though "example VLAN" is assigned to exactly the same set of site and group

Error message:

VLAN is assigned to group example group (scope: USA); cannot also assign to site New York.

This could be solved by:

  • changing VLAN to use scope as well: dcim.site and ipam.vlangroup
  • permit both but add add constrains checking during add of a VLAN and at the change of the VLAN group scope to not violate the conditions of the currently assigned VLANs to that group
  • make the usage of site and group exclusive for a VLAN. Either site or group, not both.
Originally created by @bb-Ricardo on GitHub (Feb 22, 2025). Originally assigned to: @arthanson on GitHub. ### Deployment Type NetBox Cloud ### NetBox Version v4.2.2 ### Python Version 3.12 ### Steps to Reproduce 1. create a Site "New York" 2. create as Site Group "USA" 3. assign site "New York" to Site Group "USA" 4. create a VLAN group "example group" with scope Site and and site "New York" 5. create a VLAN "example VLAN" and assign both site "New York" and and group "example group" 6. change scope of VLAN group "example group" to Site-Group and select group "USA" 7. try to create a new VLAN "example with issue" and assign both site "New York" and and group "example group" ### Expected Behavior That the VLAN "example with issue" can be assigned to VLAN group "example group" and site "New York" at the same time. ### Observed Behavior Step 7 will fail, even though "example VLAN" is assigned to exactly the same set of site and group Error message: ``` VLAN is assigned to group example group (scope: USA); cannot also assign to site New York. ``` This could be solved by: * changing VLAN to use scope as well: `dcim.site` and `ipam.vlangroup` * permit both but add add constrains checking during add of a VLAN and at the change of the VLAN group scope to not violate the conditions of the currently assigned VLANs to that group * make the usage of site and group exclusive for a VLAN. Either site or group, not both.
adam added the type: bugstatus: acceptedstatus: blockedseverity: low labels 2025-12-29 21:36:02 +01:00
adam closed this issue 2025-12-29 21:36:02 +01:00
Author
Owner

@bb-Ricardo commented on GitHub (Feb 22, 2025):

Oh, and this error also occurs when we try to change unrelated attributes of described "example VLAN" in the description above:

Sending PATCH to 'http://netbox.test:80/api/ipam/vlans/49/' with data 'b'{"tags": [{"name": "NetBox-synced"}, {"name": "Source: vcsa"}]}''

Result:

ERROR: NetBox returned: PATCH /api/ipam/vlans/49/ Bad Request
ERROR: NetBox returned body: {'__all__': ['VLAN is assigned to group example group (scope: USA); cannot also assign to site New York.']}
@bb-Ricardo commented on GitHub (Feb 22, 2025): Oh, and this error also occurs when we try to change unrelated attributes of described "example VLAN" in the description above: ``` Sending PATCH to 'http://netbox.test:80/api/ipam/vlans/49/' with data 'b'{"tags": [{"name": "NetBox-synced"}, {"name": "Source: vcsa"}]}'' ``` Result: ``` ERROR: NetBox returned: PATCH /api/ipam/vlans/49/ Bad Request ERROR: NetBox returned body: {'__all__': ['VLAN is assigned to group example group (scope: USA); cannot also assign to site New York.']} ```
Author
Owner

@bctiemann commented on GitHub (Feb 24, 2025):

It seems likely this behavior will also manifest in other structures that use scoping, not just VLAN groups/VLANs. Ideally the fix should address all such cases centrally, without redundancy, and note if possible all the object types affected by this issue.

@bctiemann commented on GitHub (Feb 24, 2025): It seems likely this behavior will also manifest in other structures that use scoping, not just VLAN groups/VLANs. Ideally the fix should address all such cases centrally, without redundancy, and note if possible all the object types affected by this issue.
Author
Owner

@artiomello commented on GitHub (Mar 27, 2025):

Interestingly enough, this works for existing VLAN objects, that are already assigned to a site/VLAN group. You can change them without this error being triggered. However, newly created VLANs are indeed affected.

@artiomello commented on GitHub (Mar 27, 2025): Interestingly enough, this works for existing VLAN objects, that are already assigned to a site/VLAN group. You can change them without this error being triggered. However, newly created VLANs are indeed affected.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10797