Bad argument to internal function / 500: server got itself in trouble

Hi!

I hope someone can point me in the right direction. After a Pi restart I’ve encountered several errors and I can’t find the origin.

My Raspberry Pi 3 is running Home Assistant OS with the latest versions (as of a few days ago). I’ve been running it succesfully for a few months now. Since a restart two days ago, every time I try to access the web interface, I get a “500 internal server error / server got itself in trouble” error.

Here are some details.

Every few seconds, /config/home-assistant.log adds this message:

2022-02-09 23:23:58 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 80, in forwarded_middleware
    from hass_nabucasa import (  # pylint: disable=import-outside-toplevel
  File "/usr/local/lib/python3.9/site-packages/hass_nabucasa/__init__.py", line 15, in <module>
    from .auth import CloudError, CognitoAuth
  File "/usr/local/lib/python3.9/site-packages/hass_nabucasa/auth.py", line 7, in <module>
    import boto3
  File "/usr/local/lib/python3.9/site-packages/boto3/__init__.py", line 16, in <module>
    from boto3.session import Session
  File "/usr/local/lib/python3.9/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/usr/local/lib/python3.9/site-packages/botocore/session.py", line 30, in <module>
    import botocore.client
  File "/usr/local/lib/python3.9/site-packages/botocore/client.py", line 26, in <module>
    from botocore.model import ServiceModel
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 846, in exec_module
  File "<frozen importlib._bootstrap_external>", line 978, in get_code
  File "<frozen importlib._bootstrap_external>", line 647, in _compile_bytecode
SystemError: Objects/codeobject.c:141: bad argument to internal function

As the last thing I did was add the Spotify integration (although that seemed successful), I tried removing its entry in /config/.storage/core.config_entries, to no avail. I also set http.ip_ban_enabled to false in my /config/configuration.yaml, as some topics mentioned that a self-banned ip could be the issue.

Note that I also cannot create a backup with the ha backup new command, because of an “unknown error, see supervisor”. When checking the logs of the supervisor, it contains this entry:

INFO (MainThread) [supervisor.jobs] 'BackupManager.do_backup_full' blocked from execution, system is not running - CoreState.STARTUP

And also this message, every 5 seconds:

ERROR (MainThread) [supervisor.homeassistant.api] Can't update Home Assistant access token!

When I try to start the core with ha core start I get another unknown error and the supervisor logs show this:

ERROR (MainThread) [supervisor.utils] Can't execute start while a task is in progress

Does anyone have an idea of where to look or what to try? My search efforts of all the mentioned errors did not result in anything. It feels like the fix is super simple, but I don’t know what my next step could be. Any suggestions?

I am experiencing the exact same error after a reboot today, did you ever end up finding a solution?

I did not. I managed to scrap enough files together from the system to restore my setup pretty well.

1 Like

Yeah, that’s what I ended up doing too. And I setup the samba auto-backup feature so I don’t have to go through it all again