fix: tolerate legacy NULL properties on pending devices
The pending_devices.properties column is added by an idempotent migration, so existing rows have properties = NULL. PendingDeviceResponse typed it as a list, so GET /scan/pending 500'd on any pre-existing device. - Coerce NULL/non-list properties to [] in PendingDeviceResponse. - Backfill existing NULL rows to '[]' in init_db migrations. - Regression test: /scan/pending returns 200 with a legacy NULL-properties row. ha-relevant: maybe
This commit is contained in:
@@ -117,6 +117,8 @@ async def init_db() -> None:
|
||||
await conn.exec_driver_sql("ALTER TABLE pending_devices ADD COLUMN discovery_source TEXT")
|
||||
with suppress(OperationalError):
|
||||
await conn.exec_driver_sql("ALTER TABLE pending_devices ADD COLUMN properties JSON")
|
||||
with suppress(OperationalError):
|
||||
await conn.exec_driver_sql("UPDATE pending_devices SET properties = '[]' WHERE properties IS NULL")
|
||||
with suppress(OperationalError):
|
||||
await conn.exec_driver_sql("ALTER TABLE scan_runs ADD COLUMN kind TEXT NOT NULL DEFAULT 'ip'")
|
||||
# --- Zigbee schema migrations (logged variant per CLAUDE.md feedback) ---
|
||||
|
||||
Reference in New Issue
Block a user