Removing currently selected spool causes an error to occur
mdziekon opened this issue · 0 comments
mdziekon commented
Problem description
In a situation where currently selected spool is being removed (as in, deleted from the database), the following error occurs:
SPM:ERROR: Load current selected spools data
An unknown error occurred while loading data
In Octoprint's console:
octoprint_1 | 2023-07-07 00:16:34,194 - octoprint - ERROR - Exception on /plugin/SpoolManager/loadSelectedSpools [GET]
octoprint_1 | Traceback (most recent call last):
octoprint_1 | File "/octoprint/plugins/lib/python3.8/site-packages/flask/app.py", line 2529, in wsgi_app
octoprint_1 | response = self.full_dispatch_request()
octoprint_1 | File "/octoprint/plugins/lib/python3.8/site-packages/flask/app.py", line 1825, in full_dispatch_request
octoprint_1 | rv = self.handle_user_exception(e)
octoprint_1 | File "/octoprint/plugins/lib/python3.8/site-packages/flask/app.py", line 1823, in full_dispatch_request
octoprint_1 | rv = self.dispatch_request()
octoprint_1 | File "/octoprint/plugins/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
octoprint_1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
octoprint_1 | File "/octoprint/plugins/lib/python3.8/site-packages/octoprint/util/__init__.py", line 1686, in wrapper
octoprint_1 | return f(*args, **kwargs)
octoprint_1 | File "/octoprint/plugins/lib/python3.8/site-packages/octoprint_SpoolManager/api/SpoolManagerAPI.py", line 929, in handleLoadSelectedSpools
octoprint_1 | for selectedSpool in self.loadSelectedSpools()
octoprint_1 | File "/octoprint/plugins/lib/python3.8/site-packages/octoprint/util/__init__.py", line 1686, in wrapper
octoprint_1 | return f(*args, **kwargs)
octoprint_1 | File "/octoprint/plugins/lib/python3.8/site-packages/octoprint_SpoolManager/api/SpoolManagerAPI.py", line 143, in loadSelectedSpools
octoprint_1 | "Last selected Spool for Tool %d from plugin-settings not found in database. Maybe deleted in the meantime." % i)
octoprint_1 | NameError: name 'i' is not defined
Proposed resolution
- Before performing the delete, check whether the spool is currently selected, and if so, deselect it
- (Optional) Add confirmation before deleting currently selected spool
Is this a regression caused by fork's changes?
No.
In fact this behavior has improved significantly compares to 1.7.0
. On that version, removing selected spool causes the entire Spool's UI to fail without an error message.