From 5ae3f9d8852653beb59ca3792f5c511a4875b1c8 Mon Sep 17 00:00:00 2001 From: "Frederik (P0x00)" Date: Sun, 9 Aug 2026 23:34:18 -0500 Subject: [PATCH 1/2] Fix: mark MgmtRtgRsp.Routes optional to prevent frame-processing crash on NOT_SUPPORTED status --- zigpy_znp/commands/zdo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zigpy_znp/commands/zdo.py b/zigpy_znp/commands/zdo.py index 6c1abbe6..982ee5f8 100644 --- a/zigpy_znp/commands/zdo.py +++ b/zigpy_znp/commands/zdo.py @@ -1194,7 +1194,7 @@ class ZDO(t.CommandsBase, subsystem=t.Subsystem.ZDO): t.Param( "Status", t.ZDOStatus, "Status is either Success (0) or Failure (1)" ), - t.Param("Routes", zigpy.zdo.types.Routes, "Routes"), + t.Param("Routes", zigpy.zdo.types.Routes, "Routes", optional=True), ), ) From 4907f4f1bfee2758751db493e13bc245c951a531 Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 4 Sep 2026 15:45:01 -0700 Subject: [PATCH 2/2] Add regression test for `MgmtRtgRsp` with `Status=NOT_SUPPORTED` Same shape as `test_neighbors_missing_payload` from #228: a real `Mgmt_Rtg_rsp` frame that ends after the status byte must deserialize with `Routes=None` instead of raising "Frame data is truncated". Co-Authored-By: Claude Fable 5.1 --- tests/test_commands.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_commands.py b/tests/test_commands.py index 705e09b2..d31c38a8 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -559,3 +559,19 @@ def test_neighbors_missing_payload(): Src=0x821F, Status=t.ZDOStatus.NOT_SUPPORTED, ) + + +def test_routes_missing_payload(): + frame = frames.GeneralFrame( + header=t.CommandHeader( + id=0xB2, + subsystem=t.Subsystem.ZDO, + type=t.CommandType.AREQ, + ), + data=b"\x85\xCC\x84", + ) + + assert c.ZDO.MgmtRtgRsp.Callback.from_frame(frame) == c.ZDO.MgmtRtgRsp.Callback( + Src=0xCC85, + Status=t.ZDOStatus.NOT_SUPPORTED, + )