Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Config flow could not be loaded" / "bad marshal data" #2673

Open
yorb opened this issue Nov 12, 2024 · 5 comments
Open

"Config flow could not be loaded" / "bad marshal data" #2673

yorb opened this issue Nov 12, 2024 · 5 comments

Comments

@yorb
Copy link

yorb commented Nov 12, 2024

IMPORTANT: Please search the issues, including closed issues, and the FAQ before opening a new issue. The template is mandatory; failure to use it will result in issue closure.

Describe the bug

After downloading from HACS and attempting to install the integration, the following error is shown:

Config flow could not be loaded: {"message":"Invalid handler specified"}

To Reproduce

  1. Uninstall AMP (if installed)
  2. (Optional) Delete AMP from HACS and remove all traces of AMP, including entries within .storage (pickle, config files), and restart
  3. Make sure AMP is downloaded from HACS (and restart if needed)
  4. Click 'Add Integration' and select AMP
  5. See error

Expected behavior

The setup config flow starts.

Screenshots

image

System details

  • Home Assistant version: 2024.11.1
  • alexa_media version (from const.py or HA startup log): N/A (can't install) but observed with v4.13.7 and v4.13.8 from HACS
  • alexapy version (from pip show alexapy in homeasssistant container or HA startup log): N/A
  • Is Amazon 2FA/2SV enabled <!---We will not debug login issues if unanswered---> (y/n): y
  • Amazon Domain: amazon.com

Debug Logs (alexa_media & alexapy)
Please provide logs.

  File "/usr/src/homeassistant/homeassistant/loader.py", line 1268, in _load_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1300, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/alexa_media/__init__.py", line 18, in <module>
    from alexapy import (
  File "/usr/local/lib/python3.12/site-packages/alexapy/__init__.py", line 16, in <module>
    from .alexaapi import AlexaAPI
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 23, in <module>
    from .alexalogin import AlexaLogin
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 35, in <module>
    from bs4 import BeautifulSoup
  File "/usr/local/lib/python3.12/site-packages/bs4/__init__.py", line 37, in <module>
    from .builder import (
  File "/usr/local/lib/python3.12/site-packages/bs4/builder/__init__.py", line 626, in <module>
    from . import _html5lib
  File "/usr/local/lib/python3.12/site-packages/bs4/builder/_html5lib.py", line 21, in <module>
    import html5lib
  File "/usr/local/lib/python3.12/site-packages/html5lib/__init__.py", line 25, in <module>
    from .html5parser import HTMLParser, parse, parseFragment
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 991, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1124, in get_code
  File "<frozen importlib._bootstrap_external>", line 753, in _compile_bytecode
ValueError: bad marshal data (invalid reference)

Note the logs above are without any AMP-specific logging added. If I add the logger config entry as per the link above, no errors are output at all since this is ERROR-level and comes from HA, not AMP. The FAQ should probably be updated to help users add logging for setup errors.

Additional context

I don't know when this started, but AMP was previously working just fine and one day I noticed it stopped (my devices were unavailable). I deleted and attempted to reinstall the integration and this started. I've tried removing all traces of AMP including deleting from HACS and redownloading (with several reboots in between), but the error is the same. So either there is some kind of critical bug in AMP setup (unlikely since this has been going on for weeks and no one else has reported it) or there is some leftover file in my installation that I don't know about. The "bad marshal data" seems like a generic python issue that is usually resolved by clearing out __pycache__, but since I've tried deleting AMP and redownloading it I'm not really sure where else it could be storing these binaries.

The UI error is the same as #2293, but the cause looks different so I'm creating a new issue.

@danielbrunt57
Copy link
Collaborator

File "/config/custom_components/alexa_media/init.py", line 18, in
from alexapy import (
File "/usr/local/lib/python3.12/site-packages/alexapy/init.py", line 16, in
from .alexaapi import AlexaAPI
File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 23, in
from .alexalogin import AlexaLogin
File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 35, in
from bs4 import BeautifulSoup
File "/usr/local/lib/python3.12/site-packages/bs4/init.py", line 37, in
from .builder import (
File "/usr/local/lib/python3.12/site-packages/bs4/builder/init.py", line 626, in
from . import _html5lib
File "/usr/local/lib/python3.12/site-packages/bs4/builder/_html5lib.py", line 21, in
import html5lib
File "/usr/local/lib/python3.12/site-packages/html5lib/init.py", line 25, in
from .html5parser import HTMLParser, parse, parseFragment

AMP is trying to import from the alexapy library and that seems to be where it's going south on you.
Check pip show alexapy in the HA container. From SSH session to homeassisstant you can sudo docker exec -it homeassistant bash to get into the main container environment and that's where alexapy lives.
The alexapy python package resides in /usr/local/lib/python/3.12/site-packages/alexapy and I suspect it's somehow messed up or missing. If it's there and pip shows the correct version then maybe deleting __pycache__ in that folder and restarting HA will resolve it...

@yorb
Copy link
Author

yorb commented Nov 12, 2024

@danielbrunt57 Thanks for the reply, that makes sense but so far I've only used the Terminal & SSH add-on which doesn't have docker, so from some googling it looks like I need to go a level deeper. Are these the instructions I should follow? I'm running HA OS on a pi, if it matters.

@danielbrunt57
Copy link
Collaborator

I'm using the Terminal & SSH add-on and I'm running Home Assistant OS on HA "Blue" ODROID N2+ and I have the docker command. Have you tried the command via SSH and it failed?

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Nov 14, 2024

The instructions you reference allow you to access the host via external SSH on port 22222 thus bypassing the need to run sudo docker exec -t homeassistant bash from the standard SSH connection that takes you inside the Advanced SSH & Web Terminal add-on docker container which only exposes the config directory from the homeassistant container.

@pappaloo
Copy link

Same exact issue. I just did an upgrade to Alexapy (sudo pip install alexapy --upgrade), and restarted HA. Solved the issue, in case any others are running into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants