Skip to content

Commit 67be4f8

Browse files
Fail creating config entry in reauth or reconfigure flows (home-assistant#154035)
1 parent 447fb68 commit 67be4f8

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

homeassistant/config_entries.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,13 +3214,11 @@ def async_create_entry( # type: ignore[override]
32143214
) -> ConfigFlowResult:
32153215
"""Finish config flow and create a config entry."""
32163216
if self.source in {SOURCE_REAUTH, SOURCE_RECONFIGURE}:
3217-
report_usage(
3218-
f"creates a new entry in a '{self.source}' flow, "
3219-
"when it is expected to update an existing entry and abort",
3220-
core_behavior=ReportBehavior.LOG,
3221-
breaks_in_ha_version="2025.11",
3222-
integration_domain=self.handler,
3217+
raise HomeAssistantError(
3218+
f"Creates a new entry in a '{self.source}' flow, "
3219+
"when it is expected to update an existing entry and abort"
32233220
)
3221+
32243222
result = super().async_create_entry(
32253223
title=title,
32263224
data=data,

tests/test_config_entries.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8887,7 +8887,7 @@ async def test_state_cache_is_cleared_on_entry_disable(hass: HomeAssistant) -> N
88878887
"source",
88888888
[config_entries.SOURCE_REAUTH, config_entries.SOURCE_RECONFIGURE],
88898889
)
8890-
async def test_create_entry_reauth_reconfigure(
8890+
async def test_create_entry_reauth_reconfigure_fails(
88918891
hass: HomeAssistant,
88928892
source: str,
88938893
original_unique_id: str | None,
@@ -8937,25 +8937,9 @@ async def _async_step_confirm(self):
89378937

89388938
with (
89398939
mock_config_flow("test", TestFlow),
8940-
patch.object(frame, "_REPORTED_INTEGRATIONS", set()),
8940+
pytest.raises(HomeAssistantError),
89418941
):
8942-
result = await getattr(entry, f"start_{source}_flow")(hass)
8943-
await hass.async_block_till_done()
8944-
assert result["type"] is FlowResultType.CREATE_ENTRY
8945-
8946-
entries = hass.config_entries.async_entries("test")
8947-
assert len(entries) == count
8948-
if count == 1:
8949-
# Show that the previous entry got binned and recreated
8950-
assert entries[0].entry_id != entry.entry_id
8951-
8952-
assert (
8953-
f"Detected that integration 'test' creates a new entry in a '{source}' flow, "
8954-
"when it is expected to update an existing entry and abort. This will stop "
8955-
"working in Home Assistant 2025.11, please create a bug report at "
8956-
"https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+"
8957-
"label%3A%22integration%3A+test%22"
8958-
) in caplog.text
8942+
await getattr(entry, f"start_{source}_flow")(hass)
89598943

89608944

89618945
async def test_async_update_entry_unique_id_collision(

0 commit comments

Comments
 (0)