EinEinfach / CaSSAndRA

Cascaded sunray server and rover application
MIT License
29 stars 17 forks source link

List index out of range on state update #63

Closed rothnic closed 1 year ago

rothnic commented 1 year ago

I'm having trouble finding exactly what is causing this, even when debugging. I think this was introduced from the patch updates. I'm using mqtt, so maybe it is related to using it. I keep getting this error:

2023-09-13 12:01:23 DEBUG MQTT: topic:ardumower/Ardumower/state message:b'{"battery_voltage":27,"position":{"x":11,"y":22.14,"delta":3.14,"solution":2,"age":0.4,"accuracy":0.02,"visible_satellites":30,"visible_satellites_dgps":27,"mow_point_index":0},"target":{"x":13.52,"y":22.13},"job":2,"sensor":0,"amps":-0.59,"map_crc":416061}'
2023-09-13 12:01:23 DEBUG Backend: Calc data from state data frame
2023-09-13 12:01:25 ERROR Exception on /_dash-update-component [POST]
Traceback (most recent call last):
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/dash.py", line 1248, in dispatch
    args_grouping = map_grouping(
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/_grouping.py", line 124, in map_grouping
    return [map_grouping(fn, g) for g in grouping]
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/_grouping.py", line 124, in <listcomp>
    return [map_grouping(fn, g) for g in grouping]
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/_grouping.py", line 129, in map_grouping
    return fn(grouping)
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/dash.py", line 1249, in <lambda>
    lambda ind: inputs_state[ind], inputs_state_indices
IndexError: list index out of range
rothnic commented 1 year ago

Some additional context that might be important:

The error occurs almost immediately after flask boots up here:

2023-09-13 12:18:47 INFO Backend: Subscriptions to the rover MQTT topics succsessfull
2023-09-13 12:18:47 DEBUG MQTT: topic:ardumower/Ardumower/state message:b'{"battery_voltage":27.07,"position":{"x":11,"y":22.14,"delta":3.14,"solution":2,"age":0.39,"accuracy":0.02,"visible_satellites":35,"visible_satellites_dgps":29,"mow_point_index":0},"target":{"x":13.52,"y":22.13},"job":2,"sensor":0,"amps":-0.61,"map_crc":416061}'
2023-09-13 12:18:47 DEBUG Backend: Calc data from state data frame
Dash is running on http://0.0.0.0:8050/

2023-09-13 12:18:49 INFO Dash is running on http://0.0.0.0:8050/

 * Serving Flask app 'app'
 * Debug mode: off
2023-09-13 12:18:52 ERROR Exception on /_dash-update-component [POST]
Traceback (most recent call last):
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/dash.py", line 1230, in dispatch
    cb = self.callback_map[output]
KeyError: 'modal-info-body.children'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/dash.py", line 1279, in dispatch
    raise KeyError(msg) from missing_callback_function
KeyError: "Callback function not found for output 'modal-info-body.children', perhaps you forgot to prepend the '@'?"
2023-09-13 12:18:52 ERROR Exception on /_dash-update-component [POST]
Traceback (most recent call last):
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/dash.py", line 1248, in dispatch
    args_grouping = map_grouping(
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/_grouping.py", line 124, in map_grouping
    return [map_grouping(fn, g) for g in grouping]
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/_grouping.py", line 124, in <listcomp>
    return [map_grouping(fn, g) for g in grouping]
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/_grouping.py", line 129, in map_grouping
    return fn(grouping)
  File "/opt/miniconda3/envs/cassandra/lib/python3.10/site-packages/dash/dash.py", line 1249, in <lambda>
    lambda ind: inputs_state[ind], inputs_state_indices
IndexError: list index out of range
rothnic commented 1 year ago

I walked back commit by commit to find where the issue started. It appears to start with this commit adding state to every page, so not related to the Patch change.

EinEinfach commented 1 year ago

It seems to be you didn't reload browser page after update components related to dash. Just reload page or reload browser.

rothnic commented 1 year ago

It seems to be you didn't reload browser page after update components related to dash. Just reload page or reload browser.

I'm not sure what was going on... maybe my phone was still connected to the server. I restarted the entire browser on the device I was working on and it still kept erroring out. Then it just started working again a moment ago without any changes or refreshing the page.

Dash seems to be quite a pain to debug.

rothnic commented 1 year ago

Closing this, it seems to be resolved now.

EinEinfach commented 1 year ago

Dash seems to be quite a pain to debug.

Agree. Go with dash wasn't my best decision