fix(scan): default check_method='ping' for approved devices

Approving a pending device created a Node with check_method=NULL, so
the status scheduler silently skipped it (scheduler.py:64 filters
falsy check_method) and the bubble stayed grey forever.

Default to 'ping' when the device has an IP, in both single and bulk
approve paths. Also persist caller-supplied check_method/check_target
in the single-approve path.

Add regression tests asserting default check_method='ping' after
approval for both endpoints.
This commit is contained in:
Pouzor
2026-05-10 20:33:49 +02:00
parent ec8f1c87f1
commit ebdf6cb55b
2 changed files with 38 additions and 0 deletions
+7
View File
@@ -133,6 +133,9 @@ async def bulk_approve_devices(
status="unknown",
services=device.services or [],
ieee_address=device.ieee_address,
# Default to ping so the status checker actually polls the new node.
# Without this the scheduler skips it (check_method NULL → no check).
check_method="ping" if device.ip else None,
)
db.add(node)
created_nodes.append(node)
@@ -230,6 +233,10 @@ async def approve_device(
status=node_data.status,
services=node_data.services or [],
ieee_address=device.ieee_address,
# Honour caller-supplied check_method, else default to ping when an IP exists
# so the scheduler doesn't silently skip the new node.
check_method=node_data.check_method or ("ping" if node_data.ip else None),
check_target=node_data.check_target,
)
db.add(node)
await db.flush()