From f5e1b5aec65b6c3d82f7eb229a68cb118bde8dfb Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Thu, 12 Sep 2024 10:41:47 -0500 Subject: [PATCH] Update to treat null name an empty string --- netbox/netbox/views/generic/bulk_views.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/netbox/netbox/views/generic/bulk_views.py b/netbox/netbox/views/generic/bulk_views.py index d05de36d370..bce40bb795f 100644 --- a/netbox/netbox/views/generic/bulk_views.py +++ b/netbox/netbox/views/generic/bulk_views.py @@ -727,12 +727,6 @@ def _rename_objects(self, form, selected_objects): renamed_pks = [] for obj in selected_objects: - # Validate that the rename will be successful and not trigger an error - if not form.cleaned_data['use_regex'] and not obj.name: - raise ValidationError({ - 'use_regex': 'You must use regex to rename and must pass uniqueness checks' - }) - # Take a snapshot of change-logged models if hasattr(obj, 'snapshot'): obj.snapshot() @@ -746,7 +740,7 @@ def _rename_objects(self, form, selected_objects): except re.error: obj.new_name = obj.name else: - obj.new_name = obj.name.replace(find, replace) + obj.new_name = (obj.name or '').replace(find, replace) renamed_pks.append(obj.pk) return renamed_pks @@ -785,10 +779,6 @@ def post(self, request): messages.error(self.request, ", ".join(e.args)) clear_events.send(sender=self) - except ValidationError as e: - messages.error(self.request, ", ".join(e.messages)) - clear_events.send(sender=self) - except (AbortRequest, PermissionsViolation) as e: logger.debug(e.message) form.add_error(None, e.message)