Prevent errors during cleaning of connections/identifiers in device registry (#144558)

This commit is contained in:
starkillerOG 2025-05-09 14:50:00 +02:00 committed by GitHub
parent 9757009d8f
commit 93fd82d1fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -575,9 +575,11 @@ class DeviceRegistryItems[_EntryTypeT: (DeviceEntry, DeletedDeviceEntry)](
"""Unindex an entry."""
old_entry = self.data[key]
for connection in old_entry.connections:
del self._connections[connection]
if connection in self._connections:
del self._connections[connection]
for identifier in old_entry.identifiers:
del self._identifiers[identifier]
if identifier in self._identifiers:
del self._identifiers[identifier]
def get_entry(
self,