Skip to content

Commit 6737a58

Browse files
committed
Fix null check for device status responses in CLI streaming
The *_with_status() methods return None on gRPC errors, but configure_device(), start_device(), and stop_device() were accessing .code without checking for None first. This caused "'NoneType' object has no attribute 'code'" errors when device operations failed.
1 parent 3aa87e9 commit 6737a58

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

synapse/cli/streaming.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ def configure_device(device, config, console):
593593

594594
# Apply the configuration to the device
595595
configure_status = device.configure_with_status(config)
596+
if configure_status is None:
597+
console.print("[bold red]Failed to configure device: connection error[/bold red]")
598+
return False
596599
if configure_status.code != StatusCode.kOk:
597600
console.print(
598601
f"[bold red]Failed to configure device: {configure_status.message}[/bold red]"
@@ -610,6 +613,9 @@ def start_device(device, console):
610613

611614
with console.status("Starting device...", spinner="bouncingBall"):
612615
start_status = device.start_with_status()
616+
if start_status is None:
617+
console.print("[bold red]Failed to start device: connection error[/bold red]")
618+
return False
613619
if start_status.code != StatusCode.kOk:
614620
console.print(
615621
f"[bold red]Failed to start device: {start_status.message}[/bold red]"
@@ -621,6 +627,9 @@ def start_device(device, console):
621627
def stop_device(device, console):
622628
with console.status("Stopping device...", spinner="bouncingBall"):
623629
stop_status = device.stop_with_status()
630+
if stop_status is None:
631+
console.print("[bold red]Failed to stop device: connection error[/bold red]")
632+
return False
624633
if stop_status.code != StatusCode.kOk:
625634
console.print(
626635
f"[bold red]Failed to stop device: {stop_status.message}[/bold red]"

0 commit comments

Comments
 (0)