NoneType AttributeError when Bulk Renaming Nameless Devices #8748

Closed
opened 2025-12-29 20:40:43 +01:00 by adam · 7 comments
Owner

Originally created by @stuntguy3000 on GitHub (Oct 16, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

3.6.3

Python version

3.8

Steps to Reproduce

  1. Create devices without a name
  2. Select and Bulk Rename those devices
  3. Disable Regex
  4. Attempt a rename operation

Of note, I am also unable to rename nameless devices with Regex on, but no error is observed.

Expected Behavior

The renaming of bulk devices operation should be successful.

Observed Behavior

<class 'AttributeError'>

'NoneType' object has no attribute 'replace'

Python version: 3.8.10
NetBox version: 3.6.3
Plugins: 
  netbox_demo: 0.3.1
Originally created by @stuntguy3000 on GitHub (Oct 16, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version 3.6.3 ### Python version 3.8 ### Steps to Reproduce 1. Create devices without a name 2. Select and Bulk Rename those devices 3. **Disable** Regex 4. Attempt a rename operation Of note, I am also unable to rename nameless devices with Regex on, but no error is observed. ### Expected Behavior The renaming of bulk devices operation should be successful. ### Observed Behavior ```python <class 'AttributeError'> 'NoneType' object has no attribute 'replace' Python version: 3.8.10 NetBox version: 3.6.3 Plugins: netbox_demo: 0.3.1 ```
adam added the type: bugstatus: acceptednetboxseverity: low labels 2025-12-29 20:40:43 +01:00
adam closed this issue 2025-12-29 20:40:43 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 17, 2023):

The error is caused by this line, which assumes the device name will be a string (as opposed to None):

51ef4fb920/netbox/netbox/views/generic/bulk_views.py (L699)

@jeremystretch commented on GitHub (Oct 17, 2023): The error is caused by this line, which assumes the device name will be a string (as opposed to None): https://github.com/netbox-community/netbox/blob/51ef4fb920acd689755af6ea9f7765b341ebfcec/netbox/netbox/views/generic/bulk_views.py#L699
Author
Owner

@jeremystretch commented on GitHub (Nov 1, 2023):

Select and Bulk Rename those devices

I'm not clear on what behavior you expect. The bulk rename function requires a "find" value, which cannot match a null name.

@arthanson's PR #14065 will effectively ignore unnamed devices, avoiding the exception. The only way I see to enable renaming unnamed devices would be to blindly apply the "replace" value, which seems very dangerous.

@jeremystretch commented on GitHub (Nov 1, 2023): > Select and Bulk Rename those devices I'm not clear on what behavior you expect. The bulk rename function requires a "find" value, which cannot match a null name. @arthanson's PR #14065 will effectively ignore unnamed devices, avoiding the exception. The only way I see to enable renaming unnamed devices would be to blindly apply the "replace" value, which seems very dangerous.
Author
Owner

@stuntguy3000 commented on GitHub (Nov 2, 2023):

I'm not clear on what behavior you expect.

The behavior I'm expecting is to be able to bulk rename unnamed devices.

Perhaps an extension to this form is suitable, e.g. a checkbox to force-match against unnamed devices

@stuntguy3000 commented on GitHub (Nov 2, 2023): > I'm not clear on what behavior you expect. The behavior I'm expecting is to be able to bulk rename unnamed devices. Perhaps an extension to this form is suitable, e.g. _a checkbox to force-match against unnamed devices_
Author
Owner

@jeremystretch commented on GitHub (Nov 2, 2023):

The behavior I'm expecting is to be able to bulk rename unnamed devices.

Renaming them all to the same name?

@jeremystretch commented on GitHub (Nov 2, 2023): > The behavior I'm expecting is to be able to bulk rename unnamed devices. Renaming them all to the same name?
Author
Owner

@stuntguy3000 commented on GitHub (Nov 2, 2023):

Renaming them all to the same name?

In this instance yes - the use case was a stack of devices were created as placeholders to fill out a rack diagram. Think things like Cable Organizer Trays or Patch Panels, they don't need unique names.

@stuntguy3000 commented on GitHub (Nov 2, 2023): > Renaming them all to the same name? In this instance yes - the use case was a stack of devices were created as placeholders to fill out a rack diagram. Think things like Cable Organizer Trays or Patch Panels, they don't need unique names.
Author
Owner

@DanSheps commented on GitHub (May 29, 2024):

The only way I see to enable renaming unnamed devices would be to blindly apply the "replace" value, which seems very dangerous.

I don't think our data model will allow this, as name would not be unique.

@DanSheps commented on GitHub (May 29, 2024): > The only way I see to enable renaming unnamed devices would be to blindly apply the "replace" value, which seems very dangerous. I don't think our data model will allow this, as name would not be unique.
Author
Owner

@DanSheps commented on GitHub (Jul 24, 2024):

I believe this was discussed during a maintainers meeting, the consensus is this:

  • We can permit devices to be renamed with RegEx, provided the RegEx forms a unique name or otherwise passes the uniqueness check
  • The RegEx must specify only the start ^ and end $ regex and nothing else (regex would be ^$)
@DanSheps commented on GitHub (Jul 24, 2024): I believe this was discussed during a maintainers meeting, the consensus is this: * We can permit devices to be renamed with RegEx, provided the RegEx forms a unique name or otherwise passes the uniqueness check * The RegEx must specify only the start `^` and end `$` regex and nothing else (regex would be `^$`)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8748