openwisp-firmware-upgrader
openwisp-firmware-upgrader copied to clipboard
[bug] Deleting DeviceConnection object for a device with DeviceFirmareImage raises HTTP 500 error
trafficstars
Steps to replicate
- Ensure that you have a celery worker running in the background
- Create a device
- Add a credential to this device from the "Credentials" tab and save the form.
- Add a firmware to this device from the "Firmware" tab and save the form. This step will create an UpgradeOperation for this device. Verify this from the "Upgrade Operations" tab.
- Delete the credentials from the "Credentials" tab and save the form.
- Try saving the form again
Actual Outcome
The application returns HTTP 500 response because of this error
Traceback (most recent call last):
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/contrib/admin/options.py", line 688, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/utils/decorators.py", line 134, in _wrapper_view
response = view_func(request, *args, **kwargs)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/views/decorators/cache.py", line 62, in _wrapper_view_func
response = view_func(request, *args, **kwargs)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/contrib/admin/sites.py", line 242, in inner
return view(request, *args, **kwargs)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/openwisp_controller/config/admin.py", line 138, in change_view
return super().change_view(request, object_id, form_url, extra_context)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/reversion/admin.py", line 162, in change_view
return super().change_view(request, object_id, form_url, extra_context)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/openwisp_utils/admin.py", line 133, in change_view
return super().change_view(
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1889, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/utils/decorators.py", line 134, in _wrapper_view
response = view_func(request, *args, **kwargs)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1747, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1797, in _changeform_view
if all_valid(formsets) and form_validated:
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/forms/formsets.py", line 579, in all_valid
return all([formset.is_valid() for formset in formsets])
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/forms/formsets.py", line 579, in <listcomp>
return all([formset.is_valid() for formset in formsets])
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/forms/formsets.py", line 384, in is_valid
self.errors
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/forms/formsets.py", line 366, in errors
self.full_clean()
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/forms/formsets.py", line 429, in full_clean
form_errors = form.errors
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/forms/forms.py", line 196, in errors
self.full_clean()
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/forms/forms.py", line 435, in full_clean
self._post_clean()
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/forms/models.py", line 486, in _post_clean
self.instance.full_clean(exclude=exclude, validate_unique=False)
File "/home/pandafy/openwisp/venv-firmware/lib/python3.8/site-packages/django/db/models/base.py", line 1477, in full_clean
self.clean()
File "/home/pandafy/openwisp/openwisp-firmware-upgrader/openwisp_firmware_upgrader/base/models.py", line 69, in clean
self.validate_upgrade_options()
File "/home/pandafy/openwisp/openwisp-firmware-upgrader/openwisp_firmware_upgrader/base/models.py", line 56, in validate_upgrade_options
if not getattr(self.upgrader_class, 'SCHEMA'):
Exception Type: AttributeError at /admin/config/device/e879d06b-672f-44c9-aa5e-561c56492663/change/
Exception Value: 'NoneType' object has no attribute 'SCHEMA'
This is partially related to https://github.com/openwisp/openwisp-firmware-upgrader/issues/249