mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Handle invalid device registry entry type (#60966)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
2fe48702f3
commit
a59ec9ca5e
@ -172,7 +172,11 @@ class DeviceRegistryStore(storage.Store):
|
||||
# From version 1.1
|
||||
for device in old_data["devices"]:
|
||||
# Introduced in 0.110
|
||||
device["entry_type"] = device.get("entry_type")
|
||||
try:
|
||||
device["entry_type"] = DeviceEntryType(device.get("entry_type"))
|
||||
except ValueError:
|
||||
device["entry_type"] = None
|
||||
|
||||
# Introduced in 0.79
|
||||
# renamed in 0.95
|
||||
device["via_device_id"] = device.get("via_device_id") or device.get(
|
||||
|
@ -252,7 +252,19 @@ async def test_migration_1_1_to_1_2(hass, hass_storage):
|
||||
"model": "model",
|
||||
"name": "name",
|
||||
"sw_version": "version",
|
||||
}
|
||||
},
|
||||
# Invalid entry type
|
||||
{
|
||||
"config_entries": [None],
|
||||
"connections": [],
|
||||
"entry_type": "INVALID_VALUE",
|
||||
"id": "invalid-entry-type",
|
||||
"identifiers": [["serial", "mock-id-invalid-entry"]],
|
||||
"manufacturer": None,
|
||||
"model": None,
|
||||
"name": None,
|
||||
"sw_version": None,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
@ -300,7 +312,23 @@ async def test_migration_1_1_to_1_2(hass, hass_storage):
|
||||
"name_by_user": None,
|
||||
"sw_version": "new_version",
|
||||
"via_device_id": None,
|
||||
}
|
||||
},
|
||||
{
|
||||
"area_id": None,
|
||||
"config_entries": [None],
|
||||
"configuration_url": None,
|
||||
"connections": [],
|
||||
"disabled_by": None,
|
||||
"entry_type": None,
|
||||
"id": "invalid-entry-type",
|
||||
"identifiers": [["serial", "mock-id-invalid-entry"]],
|
||||
"manufacturer": None,
|
||||
"model": None,
|
||||
"name_by_user": None,
|
||||
"name": None,
|
||||
"sw_version": None,
|
||||
"via_device_id": None,
|
||||
},
|
||||
],
|
||||
"deleted_devices": [],
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user