Device Name does not have to be unique when created via script. #4215

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

Originally created by @991jo on GitHub (Oct 26, 2020).

Environment

  • Python version: 3.6.8
  • NetBox version:

Steps to Reproduce

  1. add a device.
  2. run a script that adds a device with the same name as the device added in 1.

Expected Behavior

Netbox raises an exception that a device with that name already exists.

Observed Behavior

Netbox creates the device. Now there are 2 devices with the same name.
When editing one of the devices via the WebUI you get a "a device with this name exists" error

Originally created by @991jo on GitHub (Oct 26, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/g/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.6.8 * NetBox version: <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. add a device. 2. run a script that adds a device with the same name as the device added in 1. <!-- What did you expect to happen? --> ### Expected Behavior Netbox raises an exception that a device with that name already exists. <!-- What happened instead? --> ### Observed Behavior Netbox creates the device. Now there are 2 devices with the same name. When editing one of the devices via the WebUI you get a "a device with this name exists" error
adam closed this issue 2025-12-29 18:33:54 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 26, 2020):

As the custom script's author, you are responsible for ensuring the validity of data being written to the database. Please see the Django documentation on model validation for more information.

@jeremystretch commented on GitHub (Oct 26, 2020): As the custom script's author, you are responsible for ensuring the validity of data being written to the database. Please see the [Django documentation](https://docs.djangoproject.com/en/3.1/ref/models/instances/#validating-objects) on model validation for more information.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4215