Parcourir la source

Guard against rename_fields=None in submitted comprehension

The `submitted` list comprehension previously called `f in self.rename_fields`
which raises TypeError when a subclass sets rename_fields=None. Short-circuit
with `self.rename_fields and` to safely handle None, empty tuple, and populated
tuples uniformly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Brian Tiemann il y a 4 jours
Parent
commit
a3b50b4198
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  1. 1 1
      netbox/netbox/views/generic/bulk_views.py

+ 1 - 1
netbox/netbox/views/generic/bulk_views.py

@@ -962,7 +962,7 @@ class BulkRenameView(GetReturnURLMixin, BaseMultiObjectView):
             if form.is_valid():
             if form.is_valid():
                 submitted = [
                 submitted = [
                     f for f in request.POST.getlist('field_names')
                     f for f in request.POST.getlist('field_names')
-                    if f in self.rename_fields
+                    if self.rename_fields and f in self.rename_fields
                 ]
                 ]
                 if self.rename_fields and not submitted:
                 if self.rename_fields and not submitted:
                     form.add_error(None, _("Select at least one field to rename."))
                     form.add_error(None, _("Select at least one field to rename."))