mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
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:
parent
b12c69accb
commit
5856bbc07b
@ -198,15 +198,16 @@ async def async_check_ha_config_file( # noqa: C901
|
|||||||
|
|
||||||
# Check if the integration has a custom config validator
|
# Check if the integration has a custom config validator
|
||||||
config_validator = None
|
config_validator = None
|
||||||
try:
|
if integration.platforms_exists(("config",)):
|
||||||
config_validator = await integration.async_get_platform("config")
|
try:
|
||||||
except ImportError as err:
|
config_validator = await integration.async_get_platform("config")
|
||||||
# Filter out import error of the config platform.
|
except ImportError as err:
|
||||||
# If the config platform contains bad imports, make sure
|
# Filter out import error of the config platform.
|
||||||
# that still fails.
|
# If the config platform contains bad imports, make sure
|
||||||
if err.name != f"{integration.pkg_path}.config":
|
# that still fails.
|
||||||
result.add_error(f"Error importing config platform {domain}: {err}")
|
if err.name != f"{integration.pkg_path}.config":
|
||||||
continue
|
result.add_error(f"Error importing config platform {domain}: {err}")
|
||||||
|
continue
|
||||||
|
|
||||||
if config_validator is not None and hasattr(
|
if config_validator is not None and hasattr(
|
||||||
config_validator, "async_validate_config"
|
config_validator, "async_validate_config"
|
||||||
|
@ -350,6 +350,7 @@ async def test_config_platform_import_error(hass: HomeAssistant) -> None:
|
|||||||
side_effect=ImportError("blablabla"),
|
side_effect=ImportError("blablabla"),
|
||||||
),
|
),
|
||||||
patch("os.path.isfile", return_value=True),
|
patch("os.path.isfile", return_value=True),
|
||||||
|
patch("homeassistant.loader.Integration.platforms_exists", return_value=True),
|
||||||
patch_yaml_files(files),
|
patch_yaml_files(files),
|
||||||
):
|
):
|
||||||
res = await async_check_ha_config_file(hass)
|
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",
|
"homeassistant.loader.Integration.async_get_platform",
|
||||||
side_effect=[None, ImportError("blablabla")],
|
side_effect=[None, ImportError("blablabla")],
|
||||||
),
|
),
|
||||||
|
patch("homeassistant.loader.Integration.platforms_exists", return_value=True),
|
||||||
patch("os.path.isfile", return_value=True),
|
patch("os.path.isfile", return_value=True),
|
||||||
patch_yaml_files(files),
|
patch_yaml_files(files),
|
||||||
):
|
):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user