hacs / integration

HACS gives you a powerful UI to handle downloads of all your custom needs.
https://hacs.xyz
MIT License
5.18k stars 1.25k forks source link

Error in core when trying to register hacs #3596

Closed thomluther closed 4 months ago

thomluther commented 5 months ago

System Health details

System Information

version core-2024.4.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.20-haos
arch aarch64
timezone Europe/Berlin
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4345 Installed Version | 1.34.0 Stage | running Available Repositories | 1481 Downloaded Repositories | 54 HACS Data | ok
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.04.0 agent_version | 1.6.0 docker_version | 24.0.7 disk_total | 234.7 GB disk_used | 26.2 GB healthy | true supported | true board | odroid-n2 supervisor_api | ok version_api | ok installed_addons | Advanced SSH & Web Terminal (17.2.0), Studio Code Server (5.15.0), SQLite Web (4.1.2), File editor (5.8.0), Samba share (12.3.1), Home Assistant Google Drive Backup (0.112.1), Mosquitto broker (6.4.0), Whisper (2.0.0), ZeroTier One (0.18.0), Dnsmasq (1.6.0)
Dashboards dashboards | 5 -- | -- resources | 49 views | 21 mode | storage
Recorder oldest_recorder_run | 27. März 2024 um 21:56 -- | -- current_recorder_run | 9. April 2024 um 17:04 estimated_db_size | 1448.32 MiB database_engine | sqlite database_version | 3.44.2

Checklist

Describe the issue

Since I upgraded to core 2024.3, I have issues during restart. Each time HACS does not load correctly, showing the extract from the log below. When I then reload the integration from the frontend, it reloads without error.

Could this be a timing issue that was introduced along with the boot improvements from core?

Reproduction steps

  1. Restart HA
  2. HACS integration has a load error in the UI, the Side panel entry for HACS does not show up
  3. Reload of the integration works without error ...

Debug logs

Logger: homeassistant.config_entries
Quelle: config_entries.py:551
Erstmals aufgetreten: 17:04:55 (1 Vorkommnisse)
Zuletzt protokolliert: 17:04:55

Error setting up entry for hacs
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hacs/__init__.py", line 246, in async_setup_entry
    setup_result = await async_initialize_integration(hass=hass, config_entry=config_entry)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hacs/__init__.py", line 214, in async_initialize_integration
    await async_try_startup()
  File "/config/custom_components/hacs/__init__.py", line 201, in async_try_startup
    startup_result = await async_startup()
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hacs/__init__.py", line 170, in async_startup
    async_register_frontend(hass, hacs)
  File "/config/custom_components/hacs/frontend.py", line 68, in async_register_frontend
    hass.components.frontend.async_register_built_in_panel(
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1527, in __getattr__
    report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 161, in report
    _report_integration(what, integration_frame, level)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 182, in _report_integration
    report_issue = async_suggest_report_issue(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1679, in async_suggest_report_issue
    issue_tracker = async_get_issue_tracker(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1654, in async_get_issue_tracker
    integration = async_get_loaded_integration(hass, integration_domain)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1307, in async_get_loaded_integration
    cache = hass.data[DATA_INTEGRATIONS]
            ~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'integrations'

Diagnostics dump

No response

hacs-bot[bot] commented 5 months ago

Make sure you have read the issue guidelines and that you filled out the entire template.

If you have an issue identical to this, do not add comments like "same here", "i have this too", instead add a :+1: reaction to the issue description. Thanks! :+1:

ludeeus commented 5 months ago

Post a diagnostics bump file for any integration

thomluther commented 5 months ago

Here is the HACS diagnostic dump file config_entry-hacs-efd0e4f2507410ebd7f65292d2d6b0ba.json

thomluther commented 5 months ago

I really think it is a timing problem during restart. Today there was no problem during one restart, but again on another restart. The HACS reload once all is started never failed. I assume the hass object has not created the hass.data['integrations'] entry yet when HACS is querying it? File "/usr/src/homeassistant/homeassistant/loader.py", line 1307, in async_get_loaded_integration cache = hass.data[DATA_INTEGRATIONS]


KeyError: 'integrations'
So maybe a delay must be introduced, or proper error handling when hass.data.get(DATA_INTEGRATIONS) is None
ludeeus commented 4 months ago

It is not HACS that is requesting it, that is core. And hass.data['integrations'] is initialized before any integration is loaded. The current suspicion is that you have some custom integration that is messing with that. https://github.com/emontnemery/home-assistant/blob/04072cb3c1a2447200b322043a89c89e7e39d8ac/homeassistant/bootstrap.py#L262 https://github.com/emontnemery/home-assistant/blob/04072cb3c1a2447200b322043a89c89e7e39d8ac/homeassistant/loader.py#L241

ludeeus commented 4 months ago

Can you try to remove constant_modifier and then restart to see if that helps?

ludeeus commented 4 months ago

If it still is not working without that, can you post your logs from startup with debug enabled for custom_components.hacs?

thomluther commented 4 months ago

Hello This seems indeed to be related to constant_modifier which loads very early during startup. Its not really an integration, but a custom component that I use to modify some hard coded ZHA device timeouts for Aqara sensors since I did not get that to work with ZHA quirks.

I disabled the component and had no further errors on 2 restarts. Since that component is not maintained anymore, I'll have to see what to do with it and need to start research again how to reduce the ZHA device sensor timeouts otherwise...

Thanks for you assistance, I think this HACS issue can then be closed.