when editing vlans with the api, vlans without a group are considered as one group, resulting in duplicate-errors #10463

Closed
opened 2025-12-29 21:31:49 +01:00 by adam · 7 comments
Owner

Originally created by @oehTie on GitHub (Nov 11, 2024).

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.6

Python Version

3.10

Steps to Reproduce

Using the API, create a vlan without a group,
using the api, create a second vlan with the same vlan-id, this works.
using the api, create a third vlan with a different vlan-id, also without a group, this works.
using the api, change the first vlan to have the same vlan id as the second one, still without a group. This results in an error that the vlan is duplicate.

Expected Behavior

as the vlans have no group, duplicates should be allowed.

When the same steps to reproduce are executed using the Netbox Gui, it works as expected.

Observed Behavior

Error: The fields group, vid must make a unique set.

exact api calls as already posted:"

@jeremystretch here is the API call flow that will result in the error:

POST ungrouped VLAN with vid 1000 -> Success with ID 1

curl -X 'POST'
'http://localhost:8000/api/ipam/vlans/'
-H 'accept: application/json'
-H 'Authorization: Token ***'
-H 'Content-Type: application/json'
-H 'X-CSRFTOKEN: ***'
-d '{"comments":"","description":"","group":null,"name":"VLAN-1","role":1,"status":"active","vid":1000}'

POST ungrouped VLAN with vid 1000 -> Success with ID 2

curl -X 'POST'
'http://localhost:8000/api/ipam/vlans/'
-H 'accept: application/json'
-H 'Authorization: Token ***'
-H 'Content-Type: application/json'
-H 'X-CSRFTOKEN: ***'
-d '{"comments":"","description":"","group":null,"name":"VLAN-2","role":1,"status":"active","vid":1000}'
POST ungrouped VLAN with vid 1001 -> Success with ID 3

curl -X 'POST'
'http://localhost:8000/api/ipam/vlans/'
-H 'accept: application/json'
-H 'Authorization: Token ***'
-H 'Content-Type: application/json'
-H 'X-CSRFTOKEN: ***'
-d '{"comments":"","description":"","group":null,"name":"VLAN-3","role":1,"status":"active","vid":1001}'
PUT VLAN with ID 1 to update VID to 1001 -> Error: Bad request: {"non_field_errors": ["The fields group, vid must make a unique set."]}

curl -X 'PUT'
'http://localhost:8000/api/ipam/vlans/1/'
-H 'accept: application/json'
-H 'Authorization: Token ***'
-H 'Content-Type: application/json'
-H 'X-CSRFTOKEN: ***'
-d '{"comments":"","description":"","group":null,"name":"VLAN-1","role":1,"status":"active","vid":1001}'
PATCH VLAN with ID 1 to update VID to 1001 -> Error: Bad request: {"non_field_errors": ["The fields group, vid must make a unique set."]}

curl -X 'PATCH'
'http://localhost:8000/api/ipam/vlans/1/'
-H 'accept: application/json'
-H 'Authorization: Token ***'
-H 'Content-Type: application/json'
-H 'X-CSRFTOKEN: ***'
-d '{"vid":1001}'

Originally created by @oehTie on GitHub (Nov 11, 2024). ### Deployment Type Self-hosted ### Triage priority N/A ### NetBox Version v4.1.6 ### Python Version 3.10 ### Steps to Reproduce Using the API, create a vlan without a group, using the api, create a second vlan with the same vlan-id, this works. using the api, create a third vlan with a different vlan-id, also without a group, this works. using the api, change the first vlan to have the same vlan id as the second one, still without a group. This results in an error that the vlan is duplicate. ### Expected Behavior as the vlans have no group, duplicates should be allowed. When the same steps to reproduce are executed using the Netbox Gui, it works as expected. ### Observed Behavior Error: The fields group, vid must make a unique set. exact api calls as already posted:" @jeremystretch here is the API call flow that will result in the error: POST ungrouped VLAN with vid 1000 -> Success with ID 1 curl -X 'POST' \ 'http://localhost:8000/api/ipam/vlans/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"comments":"","description":"","group":null,"name":"VLAN-1","role":1,"status":"active","vid":1000}' POST ungrouped VLAN with vid 1000 -> Success with ID 2 curl -X 'POST' \ 'http://localhost:8000/api/ipam/vlans/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"comments":"","description":"","group":null,"name":"VLAN-2","role":1,"status":"active","vid":1000}' POST ungrouped VLAN with vid 1001 -> Success with ID 3 curl -X 'POST' \ 'http://localhost:8000/api/ipam/vlans/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"comments":"","description":"","group":null,"name":"VLAN-3","role":1,"status":"active","vid":1001}' PUT VLAN with ID 1 to update VID to 1001 -> Error: Bad request: {"non_field_errors": ["The fields group, vid must make a unique set."]} curl -X 'PUT' \ 'http://localhost:8000/api/ipam/vlans/1/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"comments":"","description":"","group":null,"name":"VLAN-1","role":1,"status":"active","vid":1001}' PATCH VLAN with ID 1 to update VID to 1001 -> Error: Bad request: {"non_field_errors": ["The fields group, vid must make a unique set."]} curl -X 'PATCH' \ 'http://localhost:8000/api/ipam/vlans/1/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"vid":1001}'
adam added the type: bugstatus: duplicate labels 2025-12-29 21:31:49 +01:00
adam closed this issue 2025-12-29 21:31:49 +01:00
Author
Owner

@oehTie commented on GitHub (Nov 11, 2024):

the exact api call:

curl -X 'PUT'
'http://localhost:8000/api/ipam/vlans/4060/'
-H 'accept: application/json'
-H 'Authorization: Token *****************************'
-H 'Content-Type: application/json'
-H 'X-CSRFTOKEN: ********************************************'
-d '{"comments":"","description":"","group":null,"interfaces":[],"name":"VLAN-3","role":3,"status":"active","vid":1000}'

response:

Error: Bad request: {
"non_field_errors": [
"The fields group, vid must make a unique set."
  ]
}

@oehTie commented on GitHub (Nov 11, 2024): the exact api call: curl -X 'PUT' \ 'http://localhost:8000/api/ipam/vlans/4060/' \ -H 'accept: application/json' \ -H 'Authorization: Token *****************************' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ********************************************' \ -d '{"comments":"","description":"","group":null,"interfaces":[],"name":"VLAN-3","role":3,"status":"active","vid":1000}' response: Error: Bad request: { "non_field_errors": [ "The fields group, vid must make a unique set."   ] }
Author
Owner

@jeremystretch commented on GitHub (Nov 12, 2024):

Please edit your post above to include the specific values and REST API query used in the creation of each object. This is necessary for someone to attempt to reproduce the behavior.

@jeremystretch commented on GitHub (Nov 12, 2024): Please edit your post above to include the *specific values* and REST API query used in the creation of each object. This is necessary for someone to attempt to reproduce the behavior.
Author
Owner

@bctiemann commented on GitHub (Nov 12, 2024):

Maybe a duplicate of (or at least related to) https://github.com/netbox-community/netbox/issues/17810 ?

@bctiemann commented on GitHub (Nov 12, 2024): Maybe a duplicate of (or at least related to) https://github.com/netbox-community/netbox/issues/17810 ?
Author
Owner

@ghost commented on GitHub (Nov 13, 2024):

@jeremystretch here is the API call flow that will result in the error:

POST ungrouped VLAN with vid 1000 -> Success with ID 1

curl -X 'POST' \
  'http://localhost:8000/api/ipam/vlans/' \
  -H 'accept: application/json' \
  -H 'Authorization: Token ***' \
  -H 'Content-Type: application/json' \
  -H 'X-CSRFTOKEN: ***' \
  -d '{"comments":"","description":"","group":null,"name":"VLAN-1","role":1,"status":"active","vid":1000}'

POST ungrouped VLAN with vid 1000 -> Success with ID 2

curl -X 'POST' \
  'http://localhost:8000/api/ipam/vlans/' \
  -H 'accept: application/json' \
  -H 'Authorization: Token ***' \
  -H 'Content-Type: application/json' \
  -H 'X-CSRFTOKEN: ***' \
  -d '{"comments":"","description":"","group":null,"name":"VLAN-2","role":1,"status":"active","vid":1000}'

POST ungrouped VLAN with vid 1001 -> Success with ID 3

curl -X 'POST' \
  'http://localhost:8000/api/ipam/vlans/' \
  -H 'accept: application/json' \
  -H 'Authorization: Token ***' \
  -H 'Content-Type: application/json' \
  -H 'X-CSRFTOKEN: ***' \
  -d '{"comments":"","description":"","group":null,"name":"VLAN-3","role":1,"status":"active","vid":1001}'

PUT VLAN with ID 1 to update VID to 1001 -> Error: Bad request: {"non_field_errors": ["The fields group, vid must make a unique set."]}

curl -X 'PUT' \
  'http://localhost:8000/api/ipam/vlans/1/' \
  -H 'accept: application/json' \
  -H 'Authorization: Token ***' \
  -H 'Content-Type: application/json' \
  -H 'X-CSRFTOKEN: ***' \
  -d '{"comments":"","description":"","group":null,"name":"VLAN-1","role":1,"status":"active","vid":1001}'

PATCH VLAN with ID 1 to update VID to 1001 -> Error: Bad request: {"non_field_errors": ["The fields group, vid must make a unique set."]}

curl -X 'PATCH' \
  'http://localhost:8000/api/ipam/vlans/1/' \
  -H 'accept: application/json' \
  -H 'Authorization: Token ***' \
  -H 'Content-Type: application/json' \
  -H 'X-CSRFTOKEN: ***' \
  -d '{"vid":1001}'
@ghost commented on GitHub (Nov 13, 2024): @jeremystretch here is the API call flow that will result in the error: **POST ungrouped VLAN with vid 1000 -> Success with ID 1** ``` curl -X 'POST' \ 'http://localhost:8000/api/ipam/vlans/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"comments":"","description":"","group":null,"name":"VLAN-1","role":1,"status":"active","vid":1000}' ``` **POST ungrouped VLAN with vid 1000 -> Success with ID 2** ``` curl -X 'POST' \ 'http://localhost:8000/api/ipam/vlans/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"comments":"","description":"","group":null,"name":"VLAN-2","role":1,"status":"active","vid":1000}' ``` **POST ungrouped VLAN with vid 1001 -> Success with ID 3** ``` curl -X 'POST' \ 'http://localhost:8000/api/ipam/vlans/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"comments":"","description":"","group":null,"name":"VLAN-3","role":1,"status":"active","vid":1001}' ``` **PUT VLAN with ID 1 to update VID to 1001 -> Error: Bad request: {"non_field_errors": ["The fields group, vid must make a unique set."]}** ``` curl -X 'PUT' \ 'http://localhost:8000/api/ipam/vlans/1/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"comments":"","description":"","group":null,"name":"VLAN-1","role":1,"status":"active","vid":1001}' ``` **PATCH VLAN with ID 1 to update VID to 1001 -> Error: Bad request: {"non_field_errors": ["The fields group, vid must make a unique set."]}** ``` curl -X 'PATCH' \ 'http://localhost:8000/api/ipam/vlans/1/' \ -H 'accept: application/json' \ -H 'Authorization: Token ***' \ -H 'Content-Type: application/json' \ -H 'X-CSRFTOKEN: ***' \ -d '{"vid":1001}' ```
Author
Owner

@github-actions[bot] commented on GitHub (Nov 21, 2024):

This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.

@github-actions[bot] commented on GitHub (Nov 21, 2024): This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.
Author
Owner

@oehTie commented on GitHub (Dec 1, 2024):

info added to starting post

@oehTie commented on GitHub (Dec 1, 2024): info added to starting post
Author
Owner

@jeremystretch commented on GitHub (Dec 5, 2024):

This seems like another instance of the root issue recently resolved under bug #17810, which should be fixed in the next release (v4.1.8). I'm going to mark this as resolved, but please feel free to ask that it be re-opened if you're able to reproduce the behavior on v4.1.8 once it has been released.

@jeremystretch commented on GitHub (Dec 5, 2024): This seems like another instance of the root issue recently resolved under bug #17810, which should be fixed in the next release (v4.1.8). I'm going to mark this as resolved, but please feel free to ask that it be re-opened if you're able to reproduce the behavior on v4.1.8 once it has been released.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10463