kizniche / Mycodo

An environmental monitoring and regulation system
http://kylegabriel.com/projects/
GNU General Public License v3.0
2.95k stars 494 forks source link

500 server error when saving widget configuration #1201

Closed ArBleizBZH closed 1 year ago

ArBleizBZH commented 2 years ago

Hello Kyle! I've been enjoying/admiring your videos for some time, but only just made the plunge a couple days ago, with getting a Pi and setting it up with Mycodo. My indoor garden is already going, so all the infrastructure is in place, it's mostly a question of adding inputs and outputs to get everything automated.

Anyways, the Pi and the Mycodo builds are brand new as of yesterday (debug data follows).

BUG SUMMARY: Attempting to configure an existing widget results in a 500 server error.

REPRO STEPS: These are the steps, but I'm not sure you'll be able to repro; since it's such an obvious, un-missable issue I'm guessing the cause is with my environment config.

  1. Create new Mycodo Dashboard
  2. Add a 'Gauge (Angular) [Highcharts]' or a 'Graph (Synchronous) [Highstock]' (haven't tried the others yet)
  3. Save the new dashboard widget
  4. From the dashboard page, click the widget's gear icon to access the "Configure" panel
  5. Make changes (or not) and click Save

RESULT: The browser displays a 500 Server Error with the message "AttributeError: 'NoneType' object has no attribute 'widget_add_refresh'" (full details below)

NOTES: Even though saving causes a 500, the changes are sometimes persisted nonetheless. Though I did notice that was not true for increasing the number of color stops, when I do this, the number of stops does not change in the widget, and the new stops do not get added for configuration in the config page, Though I'm thinking this is likely a separate issue.

Thanks for the help, debug data follows, let me know if you need anything more. And also, I apologize in advance as this smells like some sort of user config error or some such; I did try to track it down but couldn't. Merci Kyle!!!

FULL ERROR DUMP:

Error 500: Internal Server Error Something bad happened but it's probably not your fault. Letting the developers know about these issues is crucial to supporting Mycodo. Please submit a new issue on GitHub with the following diagnostic information and error traceback (copy the entire traceback):

Version: 8.13.10 Database: 743de2cd05e3 Model: Raspberry Pi 4 Model B Rev 1.5

Release: Distributor ID: Raspbian Description: Raspbian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye

Firmware: b''

Error (Full Traceback):

Traceback (most recent call last): File "/var/mycodo-root/env/lib/python3.9/site-packages/flask_login/utils.py", line 277, in decorated_view return current_app.ensure_sync(func)(*args, **kwargs) File "/home/ludo/Mycodo/mycodo/mycodo_flask/routes_dashboard.py", line 145, in page_dashboard utils_dashboard.widget_mod(form_base, request.form) File "/home/ludo/Mycodo/mycodo/mycodo_flask/utils/utils_dashboard.py", line 308, in widget_mod control.widget_add_refresh(mod_widget.unique_id) File "/home/ludo/Mycodo/mycodo/mycodo_client.py", line 292, in widget_add_refresh return self.proxy().widget_add_refresh(unique_id) File "/var/mycodo-root/env/lib/python3.9/site-packages/Pyro5/client.py", line 476, in call return self.send(self.name, args, kwargs) File "/var/mycodo-root/env/lib/python3.9/site-packages/Pyro5/client.py", line 243, in _pyroInvoke raise data # if you see this in your traceback, you should probably inspect the remote traceback as well AttributeError: 'NoneType' object has no attribute 'widget_add_refresh'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/var/mycodo-root/env/lib/python3.9/site-packages/flask/app.py", line 2077, in wsgi_app response = self.full_dispatch_request() File "/var/mycodo-root/env/lib/python3.9/site-packages/flask/app.py", line 1525, in full_dispatch_request rv = self.handle_user_exception(e) File "/var/mycodo-root/env/lib/python3.9/site-packages/flask_restx/api.py", line 672, in error_router return original_handler(e) File "/var/mycodo-root/env/lib/python3.9/site-packages/flask/app.py", line 1523, in full_dispatch_request rv = self.dispatch_request() File "/var/mycodo-root/env/lib/python3.9/site-packages/flask/app.py", line 1509, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(*req.view_args) File "/var/mycodo-root/env/lib/python3.9/site-packages/flask_login/utils.py", line 279, in decorated_view return func(args, **kwargs) File "/home/ludo/Mycodo/mycodo/mycodo_flask/routes_dashboard.py", line 145, in page_dashboard utils_dashboard.widget_mod(form_base, request.form) File "/home/ludo/Mycodo/mycodo/mycodo_flask/utils/utils_dashboard.py", line 308, in widget_mod control.widget_add_refresh(mod_widget.unique_id) File "/home/ludo/Mycodo/mycodo/mycodo_client.py", line 292, in widget_add_refresh return self.proxy().widget_add_refresh(unique_id) File "/var/mycodo-root/env/lib/python3.9/site-packages/Pyro5/client.py", line 476, in call return self.send(self.name, args, kwargs) File "/var/mycodo-root/env/lib/python3.9/site-packages/Pyro5/client.py", line 243, in _pyroInvoke raise data # if you see this in your traceback, you should probably inspect the remote traceback as well AttributeError: 'NoneType' object has no attribute 'widget_add_refresh'

DEBUG INFORMATION:

Mycodo Version: 8.13.10
Python Version: 3.9.2 (default, Mar 12 2021, 04:06:34) [GCC 10.2.1 20210110]
Database Version: 743de2cd05e3
Daemon Status: Running
Frontend Process ID: 521
Frontend RAM Usage: 72.356 MB
Frontend Virtualenv: Yes

uptime 06:40:34 up 9:56, 2 users, load average: 0.30, 0.13, 0.12 Kernel Information: uname -a Linux raspberrypi 5.15.32-v7l+ #1538 SMP Thu Mar 31 19:39:41 BST 2022 armv7l GNU/Linux

Processes (frontend and threads): pstree -p 521
python(521)---python(2555)-+-sh(10545)---pstree(10546)
                           |-{python}(2564)
                           `-{python}(2565)

Processes (frontend and threads): top -b -H -n 1 -p 521 top - 06:40:35 up 9:56, 2 users, load average: 0.30, 0.13, 0.12 Threads: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st MiB Mem : 922.0 total, 67.9 free, 478.4 used, 375.6 buff/cache MiB Swap: 512.0 total, 350.4 free, 161.6 used. 248.3 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 521 root 20 0 25272 3208 2224 S 0.0 0.3 0:08.42 python

I2C Bus 1: i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- 76 --                

Disk Usage: df -h Filesystem Size Used Avail Use% Mounted on /dev/root 115G 11G 99G 10% / devtmpfs 332M 0 332M 0% /dev tmpfs 461M 17M 445M 4% /dev/shm tmpfs 185M 1.3M 184M 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock /dev/mmcblk0p6 253M 50M 203M 20% /boot tmpfs 93M 24K 93M 1% /run/user/1000

Memory: free -h
               total        used        free      shared  buff/cache   available
Mem:           921Mi       478Mi        70Mi       106Mi       372Mi       248Mi
Swap:          511Mi       161Mi       350Mi

Diagnostic Messages: dmesg | tail -n 20 [30828.893014] hdmi-audio-codec hdmi-audio-codec.4.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.893024] MAI: soc_pcm_open() failed (-19) [30828.900439] hdmi-audio-codec hdmi-audio-codec.4.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.900456] MAI: soc_pcm_open() failed (-19) [30828.900797] hdmi-audio-codec hdmi-audio-codec.4.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.900812] MAI: soc_pcm_open() failed (-19) [30828.901058] hdmi-audio-codec hdmi-audio-codec.4.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.901068] MAI: soc_pcm_open() failed (-19) [30828.935413] hdmi-audio-codec hdmi-audio-codec.5.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.935439] MAI: soc_pcm_open() failed (-19) [30828.935982] hdmi-audio-codec hdmi-audio-codec.5.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.935998] MAI: soc_pcm_open() failed (-19) [30828.936496] hdmi-audio-codec hdmi-audio-codec.5.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.936513] MAI: soc_pcm_open() failed (-19) [30828.943007] hdmi-audio-codec hdmi-audio-codec.5.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.943034] MAI: soc_pcm_open() failed (-19) [30828.943457] hdmi-audio-codec hdmi-audio-codec.5.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.943480] MAI: soc_pcm_open() failed (-19) [30828.943776] hdmi-audio-codec hdmi-audio-codec.5.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [30828.943793] MAI: soc_pcm_open() failed (-19)



STOP right now, and please first look to see if the issue you're about to submit is already an open or recently closed issue at https://github.com/kizniche/Mycodo/issues

Please DO NOT OPEN AN ISSUE:

 - If your Mycodo version is not the latest release version, please update your device before submitting your issue (unless your issue is related to not being able to upgrade). Your problem might already be solved.

 - If your issue has been addressed before. If you have any new information that may aid in solving the issue, post it in the issue that already exists.

If you are going to post a new issue, next read How to Write a Good Bug Report at https://forum.radicaldiy.com/t/how-to-write-a-good-bug-report/71

Please complete as many of the sections below, if applicable, to provide the most information that may help with investigating your issue. Replace the text in brackets with your own text describing the issue. The details requested potentially affect which options to pursue. The small amount of time you spend completing the template will also help those providing assistance by reducing the time required to help you.

### Describe the problem/bug

*[A clear and concise description of what you were trying to do and what the problem/bug is - replace this with your own text]*

### Versions:

 - Mycodo Version: *[e.g. 8.0.3]*
 - Raspberry Pi Version: *[e.g. 3B+]*
 - Raspbian OS Version: *[e.g. Buster Lite]*

### Reproducibility

Please list specific setup details that are involved and the steps to reproduce the behavior:

1. *[Go to...]*
7. *[Click on...]*
8. *[Scroll down to...]*
9. *[See error...]*
10. *[replace this list with your own text]*

### Expected behavior

*[A clear and concise description of what you expected to happen - replace this with your own text]*

### Screenshots

*[If applicable, add screenshots to help explain your problem - replace this with your own text]*

### Additional context

*[Anything that should be added to make it easier to address this issue - replace this with your own text]*
kizniche commented 2 years ago

Is the daemon not running?

ArBleizBZH commented 2 years ago

I'm getting a Daemon log so I've been assuming that it is. Is there a foolproof way to check? (cuz I'm a fool who knows nothing of Mycodo, very little of Raspberry Pi and even less of Linux :D ).

Also, I noticed that when I add a widget, it always adds two of the same instead of one. The reason I wonder if this is related is because I just tried to delete one widget, and I got two status messages: Success: Delete widget with ID: 5eec230d-a8be-48d7-90c3-30382512665d × Error: Delete Widget: 'NoneType' object has no attribute 'widget_remove'

I had already deleted the duplicate, hence the error. But it got me wondering whether those extra widgets are related to the issues I have while saving. Could the widget IDs get mixed up when it's creating extraneous ones?

ArBleizBZH commented 2 years ago

Found this in the Daemon log also: 2022-06-15 06:50:19,005 - INFO - mycodo.daemon - Mycodo daemon v8.13.10 starting 2022-06-15 06:50:20,202 - INFO - mycodo.outputs.on_off_kasa_kp303_0_4_2_946252eb - Starting asyncio RPC server...

In case it's related, I did notice that the only sensor I have hooked up (BME280) was no longer reporting measurements after a system restart (issued from Mycodo). I tried to get it going again for a while in vain, but what eventually did the trick was to deactivate it and then reactivate it.

kizniche commented 1 year ago

I believe this issue has been fixed in one of the recent fixes. You can upgrade to the master branch (see the github wiki) to test prior to the next release.

kizniche commented 1 year ago

Mycodo 8.15.0 was just released. Please upgrade and let me know if the issue persists (reopen this issue).