Deduce integration from module in loader.async_get_issue_tracker (#148017)

This commit is contained in:
Erik Montnemery 2025-07-04 07:55:20 +02:00 committed by GitHub
parent 49d1d781b8
commit a3b03caead
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -1789,6 +1789,13 @@ def async_get_issue_tracker(
# If we know nothing about the integration, suggest opening an issue on HA core
return issue_tracker
if module and not integration_domain:
# If we only have a module, we can try to get the integration domain from it
if module.startswith("custom_components."):
integration_domain = module.split(".")[1]
elif module.startswith("homeassistant.components."):
integration_domain = module.split(".")[2]
if not integration:
integration = async_get_issue_integration(hass, integration_domain)

View File

@ -1143,10 +1143,10 @@ CUSTOM_ISSUE_TRACKER = "https://blablabla.com"
("hue", "homeassistant.components.hue.sensor", CORE_ISSUE_TRACKER_HUE),
("hue", None, CORE_ISSUE_TRACKER_HUE),
("bla_built_in", None, CORE_ISSUE_TRACKER_BUILT_IN),
# Integration domain is not currently deduced from module
(None, "homeassistant.components.hue.sensor", CORE_ISSUE_TRACKER),
(None, "homeassistant.components.hue.sensor", CORE_ISSUE_TRACKER_HUE),
("hue", "homeassistant.components.mqtt.sensor", CORE_ISSUE_TRACKER_HUE),
# Loaded custom integration with known issue tracker
(None, "custom_components.bla_custom.sensor", CUSTOM_ISSUE_TRACKER),
("bla_custom", "custom_components.bla_custom.sensor", CUSTOM_ISSUE_TRACKER),
("bla_custom", None, CUSTOM_ISSUE_TRACKER),
# Loaded custom integration without known issue tracker
@ -1155,6 +1155,7 @@ CUSTOM_ISSUE_TRACKER = "https://blablabla.com"
("bla_custom_no_tracker", None, None),
("hue", "custom_components.bla.sensor", None),
# Unloaded custom integration with known issue tracker
(None, "custom_components.bla_custom_not_loaded.sensor", CUSTOM_ISSUE_TRACKER),
("bla_custom_not_loaded", None, CUSTOM_ISSUE_TRACKER),
# Unloaded custom integration without known issue tracker
("bla_custom_not_loaded_no_tracker", None, None),
@ -1218,8 +1219,7 @@ async def test_async_get_issue_tracker(
("hue", "homeassistant.components.hue.sensor", CORE_ISSUE_TRACKER_HUE),
("hue", None, CORE_ISSUE_TRACKER_HUE),
("bla_built_in", None, CORE_ISSUE_TRACKER_BUILT_IN),
# Integration domain is not currently deduced from module
(None, "homeassistant.components.hue.sensor", CORE_ISSUE_TRACKER),
(None, "homeassistant.components.hue.sensor", CORE_ISSUE_TRACKER_HUE),
("hue", "homeassistant.components.mqtt.sensor", CORE_ISSUE_TRACKER_HUE),
# Custom integration with known issue tracker - can't find it without hass
("bla_custom", "custom_components.bla_custom.sensor", None),