VLAN Group site scope not working #8269

Closed
opened 2025-12-29 20:34:32 +01:00 by adam · 6 comments
Owner

Originally created by @bkampsnl on GitHub (Jun 29, 2023).

NetBox version

v3.5.2

Python version

3.8

Steps to Reproduce

  1. Create VLAN group
  2. Set scope to site A
  3. Select the edit page of an interface of a device on site B
  4. View list of VLAN group and see VLAN group you created for site A

Maybe this is the same issue as:
https://github.com/netbox-community/netbox/discussions/8523#discussion-3850724

Expected Behavior

Only vlan groups that have the scope of site A should be visible.

Observed Behavior

A vlan group that does not belong to the scope of the site is visible in the list of vlan groups.

Originally created by @bkampsnl on GitHub (Jun 29, 2023). ### NetBox version v3.5.2 ### Python version 3.8 ### Steps to Reproduce 1. Create VLAN group 2. Set scope to site A 3. Select the edit page of an interface of a device on site B 4. View list of VLAN group and see VLAN group you created for site A Maybe this is the same issue as: https://github.com/netbox-community/netbox/discussions/8523#discussion-3850724 ### Expected Behavior Only vlan groups that have the scope of site A should be visible. ### Observed Behavior A vlan group that does not belong to the scope of the site is visible in the list of vlan groups.
adam closed this issue 2025-12-29 20:34:32 +01:00
Author
Owner

@bkampsnl commented on GitHub (Jun 30, 2023):

I see in netbox/dcim/forms/model_forms.py in class class InterfaceForm :

vlan_group = DynamicModelChoiceField( queryset=VLANGroup.objects.all(), required=False, label=_('VLAN group') )

It retrieves all vlangroups, there is no scope where clause.

Is this intended ?

@bkampsnl commented on GitHub (Jun 30, 2023): I see in netbox/dcim/forms/model_forms.py in class class InterfaceForm : ` vlan_group = DynamicModelChoiceField( queryset=VLANGroup.objects.all(), required=False, label=_('VLAN group') ) ` It retrieves all vlangroups, there is no scope where clause. Is this intended ?
Author
Owner

@kkthxbye-code commented on GitHub (Jun 30, 2023):

I see in netbox/dcim/forms/model_forms.py in class class InterfaceForm :
vlan_group = DynamicModelChoiceField( queryset=VLANGroup.objects.all(), required=False, label=_('VLAN group') )
It retrieves all vlangroups, there is no scope where clause.
Is this intended ?

Yes, that is intended. The queryset is not used for filtering in DynamicModelChoiceFields.

Wether or not its intended for the VLAN group dropdown to be limited by scope I'm not sure. The VLAN fields themselves are still limited to the scope and vlan_group is not an actual field present on the interface model, so there's no actual way to choose an unavailable VLAN, so filtering the VLAN group would purely be a usability thing.

@kkthxbye-code commented on GitHub (Jun 30, 2023): > I see in netbox/dcim/forms/model_forms.py in class class InterfaceForm : >vlan_group = DynamicModelChoiceField( queryset=VLANGroup.objects.all(), required=False, label=_('VLAN group') ) >It retrieves all vlangroups, there is no scope where clause. >Is this intended ? Yes, that is intended. The queryset is not used for filtering in DynamicModelChoiceFields. Wether or not its intended for the VLAN group dropdown to be limited by scope I'm not sure. The VLAN fields themselves are still limited to the scope and vlan_group is not an actual field present on the interface model, so there's no actual way to choose an unavailable VLAN, so filtering the VLAN group would purely be a usability thing.
Author
Owner

@bkampsnl commented on GitHub (Jun 30, 2023):

I see in netbox/dcim/forms/model_forms.py in class class InterfaceForm :
vlan_group = DynamicModelChoiceField( queryset=VLANGroup.objects.all(), required=False, label=_('VLAN group') )
It retrieves all vlangroups, there is no scope where clause.
Is this intended ?

Yes, that is intended. The queryset is not used for filtering in DynamicModelChoiceFields.

Wether or not its intended for the VLAN group dropdown to be limited by scope I'm not sure. The VLAN fields themselves are still limited to the scope and vlan_group is not an actual field present on the interface model, so there's no actual way to choose an unavailable VLAN, so filtering the VLAN group would purely be a usability thing.

You are right:

You can choose any VLAN Group for an interface BUT you can only choose a VLAN that is in scope. So I guess it's not really that user friendly (because I would expect only VLAN Groups to be visible which are in scope) but the user is prevented to choose a vlan which is not in scope.

@bkampsnl commented on GitHub (Jun 30, 2023): > > I see in netbox/dcim/forms/model_forms.py in class class InterfaceForm : > > vlan_group = DynamicModelChoiceField( queryset=VLANGroup.objects.all(), required=False, label=_('VLAN group') ) > > It retrieves all vlangroups, there is no scope where clause. > > Is this intended ? > > Yes, that is intended. The queryset is not used for filtering in DynamicModelChoiceFields. > > Wether or not its intended for the VLAN group dropdown to be limited by scope I'm not sure. The VLAN fields themselves are still limited to the scope and vlan_group is not an actual field present on the interface model, so there's no actual way to choose an unavailable VLAN, so filtering the VLAN group would purely be a usability thing. You are right: You can choose any VLAN Group for an interface BUT you can only choose a VLAN that is in scope. So I guess it's not really that user friendly (because I would expect only VLAN Groups to be visible which are in scope) but the user is prevented to choose a vlan which is not in scope.
Author
Owner

@bkampsnl commented on GitHub (Jul 3, 2023):

Usability thing, not really a bug.

@bkampsnl commented on GitHub (Jul 3, 2023): Usability thing, not really a bug.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 4, 2023):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Oct 4, 2023): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Nov 3, 2023):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Nov 3, 2023): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8269