Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion openwisp_controller/config/controller/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,19 @@ def _update_device_name(self, request, device):
normalized_name = name.replace(":", "").replace("-", "").lower()
if normalized_name != normalized_mac:
device.name = name
device.skip_push_update_on_save()
# NOTE: ``device.skip_push_update_on_save()`` is defined on
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Defensive guard removed - direct method call will crash if method missing

The defensive getattr guard for skip_push_update_on_save() was removed. This will cause an AttributeError during factory-reset re-registration if the device doesn't implement this method (e.g., subclasses or older installations). The previous guarded implementation protected against this.

Suggested change
# NOTE: ``device.skip_push_update_on_save()`` is defined on
skip = getattr(device, "skip_push_update_on_save", None)
if callable(skip):
skip()
else:
logger.warning(
"Device %s does not implement skip_push_update_on_save(); "
"continuing registration without push-skip optimization.",
device.pk,
)

# AbstractDevice, but we guard the call defensively so that
# subclasses or older installations that may lack the method
# do not crash during factory-reset re-registration.
skip = getattr(device, "skip_push_update_on_save", None)
if callable(skip):
skip()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
else:
logger.warning(
"Device %s does not implement skip_push_update_on_save(); "
"continuing registration without push-skip optimization.",
device.pk,
)


class GetVpnView(SingleObjectMixin, View):
Expand Down
Loading