Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoneType AttributeError when Bulk Renaming Nameless Devices #14044

Closed
stuntguy3000 opened this issue Oct 16, 2023 · 7 comments · Fixed by #17212
Closed

NoneType AttributeError when Bulk Renaming Nameless Devices #14044

stuntguy3000 opened this issue Oct 16, 2023 · 7 comments · Fixed by #17212
Assignees
Labels
netbox severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@stuntguy3000
Copy link
Contributor

stuntguy3000 commented Oct 16, 2023

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
@stuntguy3000 stuntguy3000 added the type: bug A confirmed report of unexpected behavior in the application label Oct 16, 2023
@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available labels Oct 17, 2023
@jeremystretch
Copy link
Member

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

obj.new_name = obj.name.replace(find, replace)

@arthanson arthanson self-assigned this Oct 17, 2023
@arthanson arthanson removed the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Oct 17, 2023
@jeremystretch
Copy link
Member

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.

@stuntguy3000
Copy link
Contributor Author

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

@jeremystretch
Copy link
Member

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

Renaming them all to the same name?

@stuntguy3000
Copy link
Contributor Author

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.

@arthanson arthanson added the status: accepted This issue has been accepted for implementation label Dec 7, 2023
@arthanson arthanson added the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Apr 18, 2024
@arthanson arthanson removed their assignment Apr 18, 2024
@DanSheps DanSheps self-assigned this May 29, 2024
@DanSheps DanSheps added status: under review Further discussion is needed to determine this issue's scope and/or implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation status: accepted This issue has been accepted for implementation labels May 29, 2024
@DanSheps
Copy link
Member

DanSheps commented 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 DanSheps added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Jun 20, 2024
@DanSheps
Copy link
Member

DanSheps commented 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 DanSheps added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Aug 18, 2024
@DanSheps DanSheps self-assigned this Aug 18, 2024
DanSheps added a commit that referenced this issue Aug 20, 2024
* Allow regex renaming of unnamed devices (already allowed actually)
* Catch errors relating to unnamed devices or integrity errors as a result of the rename process
@jeremystretch jeremystretch added the netbox label Nov 1, 2024 — with Linear
@jeremystretch jeremystretch self-assigned this Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
netbox severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
4 participants