Bulk import prefixes with associated VLAN not working when multiple VLANs with the same vid exist. #10739

Closed
opened 2025-12-29 21:35:23 +01:00 by adam · 6 comments
Owner

Originally created by @gabrielmarmen on GitHub (Feb 5, 2025).

Originally assigned to: @renatoalmeidaoliveira on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.2.3

Python Version

3.12

Steps to Reproduce

  1. Create multiple VLAN entries with the same vid but associated to different sites. I use this to represent VLANs with the same vid, but located in different sites with different prefixes.

  2. Import prefix csv with the following fields: prefix, status, role, scope_type, scope_id, vlan. Include the previously added VLANs vid in the "vlan" field.

  3. The import will fail because multiple vlans with the same vid exist

Image

Expected Behavior

Import succeeds associating the right vlan depending on the DCIM.site value. The import should use the VLAN with the specified vid contained in the specified scope (site).

To fix this issue, it could also be possible to specify the VLAN object ID instead of the vid to avoid confusion.

Observed Behavior

Import fails with error :

Image

Originally created by @gabrielmarmen on GitHub (Feb 5, 2025). Originally assigned to: @renatoalmeidaoliveira on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.2.3 ### Python Version 3.12 ### Steps to Reproduce 1. Create multiple VLAN entries with the same vid but associated to different sites. I use this to represent VLANs with the same vid, but located in different sites with different prefixes. 2. Import prefix csv with the following fields: prefix, status, role, scope_type, scope_id, vlan. Include the previously added VLANs vid in the "vlan" field. 3. The import will fail because multiple vlans with the same vid exist ![Image](https://github.com/user-attachments/assets/c3a33b02-f057-4254-98b9-96e8bcf6ba1e) ### Expected Behavior Import succeeds associating the right vlan depending on the DCIM.site value. The import should use the VLAN with the specified vid contained in the specified scope (site). To fix this issue, it could also be possible to specify the VLAN object ID instead of the vid to avoid confusion. ### Observed Behavior Import fails with error : ![Image](https://github.com/user-attachments/assets/c3a33b02-f057-4254-98b9-96e8bcf6ba1e)
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:35:23 +01:00
adam closed this issue 2025-12-29 21:35:23 +01:00
Author
Owner

@jeremystretch commented on GitHub (Feb 7, 2025):

Please provide the specific data you're using to reproduce the bug.

@jeremystretch commented on GitHub (Feb 7, 2025): Please provide the specific data you're using to reproduce the bug.
Author
Owner

@steve-hbt commented on GitHub (Feb 10, 2025):

Please provide the specific data you're using to reproduce the bug.

Hi, same issue here in 4.2.1

Here my csv import :

prefix;status;scope_type;scope_id;vlan
192.168.65.0/24;active;dcim.site;13;565
172.17.65.0/24;active;dcim.site;13;17
172.23.65.0/24;active;dcim.site;13;23
10.88.65.0/24;active;dcim.site;13;888
172.18.65.0/24;active;dcim.site;13;18
172.16.65.0/24;active;dcim.site;13;16

And error : Record 2 vlan: "17" is not a unique value for this field; multiple objects were found

VLAN ID 565 is unique and others VLAN exists on all my others sites.
VLAN 17 is created on my site id "13"

Thanks !

@steve-hbt commented on GitHub (Feb 10, 2025): > Please provide the specific data you're using to reproduce the bug. Hi, same issue here in 4.2.1 Here my csv import : ``` prefix;status;scope_type;scope_id;vlan 192.168.65.0/24;active;dcim.site;13;565 172.17.65.0/24;active;dcim.site;13;17 172.23.65.0/24;active;dcim.site;13;23 10.88.65.0/24;active;dcim.site;13;888 172.18.65.0/24;active;dcim.site;13;18 172.16.65.0/24;active;dcim.site;13;16 ``` **And error :** Record 2 vlan: "17" is not a unique value for this field; multiple objects were found VLAN ID 565 is unique and others VLAN exists on all my others sites. VLAN 17 is created on my site id "13" Thanks !
Author
Owner

@gabrielmarmen commented on GitHub (Feb 11, 2025):

Please provide the specific data you're using to reproduce the bug.

Hi, same issue here in 4.2.1

Here my csv import :

prefix;status;scope_type;scope_id;vlan
192.168.65.0/24;active;dcim.site;13;565
172.17.65.0/24;active;dcim.site;13;17
172.23.65.0/24;active;dcim.site;13;23
10.88.65.0/24;active;dcim.site;13;888
172.18.65.0/24;active;dcim.site;13;18
172.16.65.0/24;active;dcim.site;13;16

And error : Record 2 vlan: "17" is not a unique value for this field; multiple objects were found

VLAN ID 565 is unique and others VLAN exists on all my others sites. VLAN 17 is created on my site id "13"

Thanks !

Thanks, this corresponds to approximatly what I have.

@gabrielmarmen commented on GitHub (Feb 11, 2025): > > Please provide the specific data you're using to reproduce the bug. > > Hi, same issue here in 4.2.1 > > Here my csv import : > > ``` > prefix;status;scope_type;scope_id;vlan > 192.168.65.0/24;active;dcim.site;13;565 > 172.17.65.0/24;active;dcim.site;13;17 > 172.23.65.0/24;active;dcim.site;13;23 > 10.88.65.0/24;active;dcim.site;13;888 > 172.18.65.0/24;active;dcim.site;13;18 > 172.16.65.0/24;active;dcim.site;13;16 > ``` > > **And error :** Record 2 vlan: "17" is not a unique value for this field; multiple objects were found > > VLAN ID 565 is unique and others VLAN exists on all my others sites. VLAN 17 is created on my site id "13" > > Thanks ! Thanks, this corresponds to approximatly what I have.
Author
Owner

@majorwolf commented on GitHub (Feb 11, 2025):

Encountered this issue today on 4.2.1. The only workaround was to remove the conflicting VLAN ID's and then manually reassign them after they got added.

In this case, we have two sites with conflicting VLAN ID's. The import function doesn't seem to check the site ID first before checking the VLAN ID to see if it conflicts.

@majorwolf commented on GitHub (Feb 11, 2025): Encountered this issue today on 4.2.1. The only workaround was to remove the conflicting VLAN ID's and then manually reassign them after they got added. In this case, we have two sites with conflicting VLAN ID's. The import function doesn't seem to check the site ID first before checking the VLAN ID to see if it conflicts.
Author
Owner

@jeremystretch commented on GitHub (Feb 12, 2025):

@Steve-Hubert @gabrielmarmen @majorwolf would any of you like to volunteer for this work?

@jeremystretch commented on GitHub (Feb 12, 2025): @Steve-Hubert @gabrielmarmen @majorwolf would any of you like to volunteer for this work?
Author
Owner

@steve-hbt commented on GitHub (Feb 12, 2025):

@Steve-Hubert @gabrielmarmen @majorwolf would any of you like to volunteer for this work?

@jeremystretch I can do tests if needed

@steve-hbt commented on GitHub (Feb 12, 2025): > [@Steve-Hubert](https://github.com/Steve-Hubert) [@gabrielmarmen](https://github.com/gabrielmarmen) [@majorwolf](https://github.com/majorwolf) would any of you like to volunteer for this work? @jeremystretch I can do tests if needed
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10739