Add missing platforms_exist guard to check_config (#114600)

* Add missing platforms_exist guard to check_config

related issue #112811

When the exception hits, the config will end up being saved in the traceback
so the memory is never released.

This matches the check_config code to homeassistant.config to avoid having
the exception thrown.

* patch

* merge branch
This commit is contained in:
J. Nick Koston 2024-04-01 15:37:30 -10:00 committed by GitHub
parent b12c69accb
commit 5856bbc07b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 9 deletions

View File

@ -198,6 +198,7 @@ async def async_check_ha_config_file( # noqa: C901
# Check if the integration has a custom config validator
config_validator = None
if integration.platforms_exists(("config",)):
try:
config_validator = await integration.async_get_platform("config")
except ImportError as err:

View File

@ -350,6 +350,7 @@ async def test_config_platform_import_error(hass: HomeAssistant) -> None:
side_effect=ImportError("blablabla"),
),
patch("os.path.isfile", return_value=True),
patch("homeassistant.loader.Integration.platforms_exists", return_value=True),
patch_yaml_files(files),
):
res = await async_check_ha_config_file(hass)
@ -373,6 +374,7 @@ async def test_platform_import_error(hass: HomeAssistant) -> None:
"homeassistant.loader.Integration.async_get_platform",
side_effect=[None, ImportError("blablabla")],
),
patch("homeassistant.loader.Integration.platforms_exists", return_value=True),
patch("os.path.isfile", return_value=True),
patch_yaml_files(files),
):