Protect hass data keys in setup.py (#142589)

This commit is contained in:
Erik Montnemery
2025-04-09 15:27:52 +02:00
committed by GitHub
parent 075a0ad780
commit 170e6bdcab
3 changed files with 110 additions and 67 deletions

View File

@ -72,12 +72,12 @@ from .helpers.json import json_bytes, json_bytes_sorted, json_fragment
from .helpers.typing import UNDEFINED, ConfigType, DiscoveryInfoType, UndefinedType
from .loader import async_suggest_report_issue
from .setup import (
DATA_SETUP_DONE,
SetupPhases,
async_pause_setup,
async_process_deps_reqs,
async_setup_component,
async_start_setup,
async_wait_component,
)
from .util import ulid as ulid_util
from .util.async_ import create_eager_task
@ -2701,11 +2701,7 @@ class ConfigEntries:
Config entries which are created after Home Assistant is started can't be waited
for, the function will just return if the config entry is loaded or not.
"""
setup_done = self.hass.data.get(DATA_SETUP_DONE, {})
if setup_future := setup_done.get(entry.domain):
await setup_future
# The component was not loaded.
if entry.domain not in self.hass.config.components:
if not await async_wait_component(self.hass, entry.domain):
return False
return entry.state is ConfigEntryState.LOADED