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

Closed
opened 2025-12-29 21:48:54 +01:00 by adam · 1 comment
Owner

Originally created by @jeroendev-one on GitHub (Oct 13, 2025).

Originally assigned to: @jnovinger on GitHub.

NetBox Edition

NetBox Community

NetBox Version

v4.4.2

Python Version

3.10

Steps to Reproduce

The issue seems to be returning here. When importing the prefixes bulk below I get the following error:

Record 1 vlan: "1" is not a unique value for this field; multiple objects were found
prefix;status;vlan_site;vlan;scope_type;scope_id;description
10.11.0.0/22;active;LOC02-MGMT;1;dcim.site;5;LOC02-MGMT

We have multiple sites with the same VLAN id, we re-use them same as the existing issue. However, it doesn't seem to be using the field 'vlan_site' to check whether the VLAN is unique for this one.

Expected Behavior

Import the prefixes and assign VLAN based on VLAN site and not only ID.

Observed Behavior

Unique constraint error.

Originally created by @jeroendev-one on GitHub (Oct 13, 2025). Originally assigned to: @jnovinger on GitHub. ### NetBox Edition NetBox Community ### NetBox Version v4.4.2 ### Python Version 3.10 ### Steps to Reproduce The issue seems to be returning here. When importing the prefixes bulk below I get the following error: ``` Record 1 vlan: "1" is not a unique value for this field; multiple objects were found ``` ```csv prefix;status;vlan_site;vlan;scope_type;scope_id;description 10.11.0.0/22;active;LOC02-MGMT;1;dcim.site;5;LOC02-MGMT ``` We have multiple sites with the same VLAN id, we re-use them same as the existing issue. However, it doesn't seem to be using the field 'vlan_site' to check whether the VLAN is unique for this one. ### Expected Behavior Import the prefixes and assign VLAN based on VLAN site and not only ID. ### Observed Behavior Unique constraint error.
adam added the type: bugstatus: acceptednetboxseverity: low labels 2025-12-29 21:48:54 +01:00
adam closed this issue 2025-12-29 21:48:54 +01:00
Author
Owner

@bctiemann commented on GitHub (Oct 13, 2025):

Linking the previous PR for reference.

It's not clear to me why this previous fix would have addressed the issue of enforcing uniqueness across the combined vlan+vlan_site rather than just on the vlan field; this error is being raised from CSVModelChoiceField.to_python which has no knowledge of any other fields, so any place in the code that tries to render that value will run into that error.

I'm trying to find another example of a NetBoxModelImportForm where multiple fields are used for uniqueness checking but I'm coming up blank. I'm sure there are some to use as reference though.

@bctiemann commented on GitHub (Oct 13, 2025): Linking the [previous PR](https://github.com/netbox-community/netbox/pull/18844) for reference. It's not clear to me why this previous fix would have addressed the issue of enforcing uniqueness across the combined vlan+vlan_site rather than just on the vlan field; this error is being raised from `CSVModelChoiceField.to_python` which has no knowledge of any other fields, so any place in the code that tries to render that value will run into that error. I'm trying to find another example of a `NetBoxModelImportForm` where multiple fields are used for uniqueness checking but I'm coming up blank. I'm sure there are some to use as reference though.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11713