Add device with same name fails #6991

Closed
opened 2025-12-29 19:47:32 +01:00 by adam · 3 comments
Owner

Originally created by @GubblGubbl on GitHub (Sep 16, 2022).

NetBox version

v.3.3.3

Python version

3.10

Steps to Reproduce

  1. Create site a
  2. Create location a on site a
  3. Create location b on site a
  4. Create device a on site a location a
  5. Create device a on site a location b

Expected Behavior

Device a will be created on both locations.

Observed Behavior

Device a is created on location a.
Creating device a on location b results in "A device with this name already exists."

Originally created by @GubblGubbl on GitHub (Sep 16, 2022). ### NetBox version v.3.3.3 ### Python version 3.10 ### Steps to Reproduce 1. Create site a 2. Create location a on site a 3. Create location b on site a 4. Create device a on site a location a 5. Create device a on site a location b ### Expected Behavior Device a will be created on both locations. ### Observed Behavior Device a is created on location a. Creating device a on location b results in "A device with this name already exists."
adam added the type: bug label 2025-12-29 19:47:32 +01:00
adam closed this issue 2025-12-29 19:47:33 +01:00
Author
Owner

@dreng commented on GitHub (Sep 16, 2022):

This might be considered a bug, but honestly you should definitely develop a proper naming convention that takes into account all sites and locations. You should never have duplicate names if you do it properly.

@dreng commented on GitHub (Sep 16, 2022): This might be considered a bug, but honestly you should definitely develop a proper naming convention that takes into account all sites and locations. You should never have duplicate names if you do it properly.
Author
Owner

@GubblGubbl commented on GitHub (Sep 16, 2022):

We discovered this behavior accidentally by importing devices not with live data :)

@GubblGubbl commented on GitHub (Sep 16, 2022): We discovered this behavior accidentally by importing devices not with live data :)
Author
Owner

@kkthxbye-code commented on GitHub (Sep 16, 2022):

As far as I know this is intended and as such is not a bug. If you want to suggest a change it must be raised as a feature request.

From the documentation.

Device names must be unique within a site, unless the device has been assigned to a tenant. Devices may also be unnamed.

1d033bd286/netbox/dcim/models/devices.py (L682-L691)

1d033bd286/netbox/dcim/models/devices.py (L652-L658)

In short, uniqueness of devices is based on name, tenant and site. So you cannot have two devices with the same name on the same site with the same tenant. If you want location to be part of the uniqueness constraint it must be raised as a FR, however it would require some very convincing arguments imo.

@kkthxbye-code commented on GitHub (Sep 16, 2022): As far as I know this is intended and as such is not a bug. If you want to suggest a change it must be raised as a feature request. [From the documentation.](https://demo.netbox.dev/static/docs/models/dcim/device/) > Device names must be unique within a site, unless the device has been assigned to a tenant. Devices may also be unnamed. https://github.com/netbox-community/netbox/blob/1d033bd286f605dd4c500b3808cb496b347d4d3c/netbox/dcim/models/devices.py#L682-L691 https://github.com/netbox-community/netbox/blob/1d033bd286f605dd4c500b3808cb496b347d4d3c/netbox/dcim/models/devices.py#L652-L658 In short, uniqueness of devices is based on name, tenant and site. So you cannot have two devices with the same name on the same site with the same tenant. If you want location to be part of the uniqueness constraint it must be raised as a FR, however it would require some very convincing arguments imo.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6991