Don't create repairs asking user to remove duplicate ignored config entries (#130056)
This commit is contained in:
parent
0e324c074a
commit
c5e3ba536c
2 changed files with 18 additions and 1 deletions
|
@ -2437,6 +2437,17 @@ class ConfigEntries:
|
|||
|
||||
for domain, unique_ids in self._entries._domain_unique_id_index.items(): # noqa: SLF001
|
||||
for unique_id, entries in unique_ids.items():
|
||||
# We might mutate the list of entries, so we need a copy to not mess up
|
||||
# the index
|
||||
entries = list(entries)
|
||||
|
||||
# There's no need to raise an issue for ignored entries, we can
|
||||
# safely remove them once we no longer allow unique id collisions.
|
||||
# Iterate over a copy of the copy to allow mutating while iterating
|
||||
for entry in list(entries):
|
||||
if entry.source == SOURCE_IGNORE:
|
||||
entries.remove(entry)
|
||||
|
||||
if len(entries) < 2:
|
||||
continue
|
||||
issue_id = f"{ISSUE_UNIQUE_ID_COLLISION}_{domain}_{unique_id}"
|
||||
|
|
|
@ -7224,6 +7224,12 @@ async def test_unique_id_collision_issues(
|
|||
for _ in range(6):
|
||||
test3.append(MockConfigEntry(domain="test3", unique_id="not_unique"))
|
||||
await manager.async_add(test3[-1])
|
||||
# Add an ignored config entry
|
||||
await manager.async_add(
|
||||
MockConfigEntry(
|
||||
domain="test2", unique_id="group_1", source=config_entries.SOURCE_IGNORE
|
||||
)
|
||||
)
|
||||
|
||||
# Check we get one issue for domain test2 and one issue for domain test3
|
||||
assert len(issue_registry.issues) == 2
|
||||
|
@ -7270,7 +7276,7 @@ async def test_unique_id_collision_issues(
|
|||
(HOMEASSISTANT_DOMAIN, "config_entry_unique_id_collision_test2_group_2"),
|
||||
}
|
||||
|
||||
# Remove the last test2 group2 duplicate, a new issue is created
|
||||
# Remove the last test2 group2 duplicate, the issue is cleared
|
||||
await manager.async_remove(test2_group_2[1].entry_id)
|
||||
assert not issue_registry.issues
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue