fix(devices): preserve existing URL on PATCH-without-url
When a PATCH omits `url` (rename / icon-only edit), normalized_url arrived at the processor as None and the manager kept whatever it had cached — or refused to re-sync if it had nothing. Fall back to existing.url so the processor is always told the current address. Surfaced by the production-review backlog.
This commit is contained in:
@@ -640,11 +640,18 @@ async def update_device(
|
|||||||
icon_color=update_data.icon_color,
|
icon_color=update_data.icon_color,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Sync connection info in processor manager
|
# Sync connection info in processor manager.
|
||||||
|
#
|
||||||
|
# When a PATCH omits `url` (rename / icon-only edit) `normalized_url`
|
||||||
|
# is None — fall back to the existing record's URL so the processor
|
||||||
|
# is always told the current address, otherwise it silently keeps
|
||||||
|
# whatever it had cached (or worse, treats None as "unconfigured"
|
||||||
|
# and refuses to re-sync).
|
||||||
|
effective_url = normalized_url if normalized_url is not None else existing.url
|
||||||
try:
|
try:
|
||||||
manager.update_device_info(
|
manager.update_device_info(
|
||||||
device_id,
|
device_id,
|
||||||
device_url=normalized_url,
|
device_url=effective_url,
|
||||||
led_count=normalized_led_count,
|
led_count=normalized_led_count,
|
||||||
baud_rate=update_data.baud_rate,
|
baud_rate=update_data.baud_rate,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user