Skip to content

Commit b3e3f55

Browse files
Codexclaude
andcommitted
fix(controller): guard missing skip_push_update_on_save in register
DeviceRegisterView._update_device_name calls ``device.skip_push_update_on_save()`` when an agent re-registers with a hostname different from the MAC address. That method is referenced in the view but is not implemented on the Device model, so every such re-registration crashes with an HTTP 500: AttributeError: 'Device' object has no attribute 'skip_push_update_on_save' This breaks the consistent_registration / factory-reset workflow: a router that loses its local UUID/key after a firstboot tries to re-register and gets a 500 error instead of finding its existing record by consistent_key. Wrap the call in ``getattr`` so the registration succeeds whether the helper method exists or not. The actual method can be re-introduced separately without changing this site. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5270e09 commit b3e3f55

File tree

1 file changed

+9
-1
lines changed
  • openwisp_controller/config/controller

1 file changed

+9
-1
lines changed

openwisp_controller/config/controller/views.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,15 @@ def _update_device_name(self, request, device):
538538
normalized_name = name.replace(":", "").replace("-", "").lower()
539539
if normalized_name != normalized_mac:
540540
device.name = name
541-
device.skip_push_update_on_save()
541+
# NOTE: upstream openwisp-controller 1.2 calls
542+
# ``device.skip_push_update_on_save()`` here, but that method
543+
# was never implemented on the Device model, causing every
544+
# re-registration with a non-MAC hostname to crash with
545+
# AttributeError. We guard the call so missing methods don't
546+
# break factory-reset re-registration.
547+
skip = getattr(device, "skip_push_update_on_save", None)
548+
if callable(skip):
549+
skip()
542550

543551

544552
class GetVpnView(SingleObjectMixin, View):

0 commit comments

Comments
 (0)