diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 1d8d7e8e98f..84d9cd2a72f 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -576,6 +576,9 @@ async def async_get_integration(hass: HomeAssistant, domain: str) -> Integration async def _async_get_integration(hass: HomeAssistant, domain: str) -> Integration: + if "." in domain: + raise ValueError(f"Invalid domain {domain}") + # Instead of using resolve_from_root we use the cache of custom # components to find the integration. if integration := (await async_get_custom_components(hass)).get(domain): diff --git a/tests/test_loader.py b/tests/test_loader.py index c51e805f400..2bffee75d1e 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -540,3 +540,9 @@ async def test_custom_integration_missing(hass, caplog): with pytest.raises(loader.IntegrationNotFound): await loader.async_get_integration(hass, "test1") + + +async def test_validation(hass): + """Test we raise if invalid domain passed in.""" + with pytest.raises(ValueError): + await loader.async_get_integration(hass, "some.thing")