Repository navigation
Conversation
Z-Stack reports a failed Simple_Desc_rsp (any non-SUCCESS status, e.g. NOT_ACTIVE or INVALID_EP) as a "default" error response, MtZdoDef_rsp (0x0040), sent as AREQ 0xC0 with NWK + Status. 0xC0 is also ZDO.StateChangeInd, so parsing fails with "trailing data" and the frame is logged as an error, although the full response is also received as a ZDO.MsgCbIncoming callback. Ignore it.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change to suppress noisy ZDO error-response tracebacks.
No open issues 🎉
What changed in this PR
Prevents noisy error tracebacks during device interviews by tolerating Z-Stack’s default ZDO error response. The full response remains available through ZDO.MsgCbIncoming.
Changes:
- Ignore three-byte responses that share the
StateChangeIndidentifier, logging them at DEBUG level. - Add a regression test for an
INVALID_EPresponse, verifying it produces no WARNING-or-higher logs.
| File | Description |
|---|---|
zigpy_znp/api.py |
Recognizes and ignores the default ZDO error response after parsing fails. |
tests/api/test_request.py |
Tests that the response is ignored without warning or error logs. |
Review effort: Balanced
|
The failed tests seem unrelated. The new |
zigpy-review-bot
left a comment
There was a problem hiding this comment.
Looks good. The firmware claim checks out, the new branch can't swallow a real StateChangeInd, and the new test fails on dev and passes here.
CI is red, but not because of this PR: locally with zigpy 2.4.1 (which the open zigpy>=1.5.0 pin installs today), the same 137 tests/application/ tests fail on dev too. They hit CommandNotRecognized because the test server has no handler for an AF.DataRequestExt broadcast to endpoint 242, cluster 0x0021 (Green Power). #291 fails CI the same way.
Verified (6 checks)
- Firmware (TI SDK at the commit the body links): in
mt_zdo.c,MT_ZdoHandleExceptions()setsdoDefaultonly in theSimple_Desc_rspcase withDataLength <= 5. That case rewritesclusterIdtoMtZdoDef_rsp(0x0040) and setsDataLength = 2.MT_ZdoDirectCB()then sendsDataLength - 1 + 2= 3 bytes (SrcAddrLE +Status) as AREQ0x40 | 0x80= 0xC0. No other ZDO response takes that path: failed NWK/IEEE address responses are dropped, not defaulted. Sob"\xd6\xde\x82"is NWK 0xDED6 with statusINVALID_EP, as the test comment says. - A real state change can't hit the branch:
MT_ZdoStateChangeCB()sendsMT_ZDO_STATE_CHANGE_INDwith length 1, so a genuineStateChangeIndparses normally. Thelen(frame.data) == 3check only runs inside theexcept ValueErrorpath, after a failed parse. - zigpy still sees the failure:
zigpy_znp/zigbee/application.py:166registersZDO.MsgCallbackRegister(ClusterId=0xFFFF), so the fullSimple_Desc_rspstill arrives asZDO.MsgCbIncomingand goes throughon_zdo_message. The only 0xC0 listeners in zigpy-znp are theStartingAsCoordinator/StartedAsCoordinatormatches inZNP.start_network, and a 3-byte frame never matched those either. - The test exercises the branch: with
dev'szigpy_znp/api.py,test_handling_zdo_default_error_rspfails with thecontains trailing data after parsingValueErrorfrom the PR body. With the PR,tests/api/test_request.pypasses (17 passed). - Full suite: on the PR head, 137 failed and 260 passed. With
dev'sapi.pyswapped in, the list of failing tests is identical (diffed), so none of them come from this change. - An independent static second-opinion pass (two models) found no correctness issues.
Z-Stack reports a failed
Simple_Desc_rsp(any non-SUCCESS status, e.g.NOT_ACTIVEorINVALID_EP) as a "default" error response, which shares its AREQ ID withZDO.StateChangeInd. zigpy-znp parses it asStateChangeInd, fails on the trailing bytes, anduart.pylogs an ERROR traceback every time a device with such an endpoint is interviewed. The full response also arrives asZDO.MsgCbIncoming, so nothing is lost. This ignores the frame at DEBUG level, next to the existingParentAnnceRsptolerance.Why 0xC0
From TI's Z-Stack MT layer (simplelink-lowpower-f2-sdk@3615ad5):
mt_zdo.cL2269-L2290:MT_ZdoHandleExceptions()rewrites aSimple_Desc_rspwithDataLength <= 5(no descriptor) toclusterId = MtZdoDef_rsp,DataLength = 2.mt.hL397-L398:MtZdoDef_rspis0x0040("Some arbitrarily chosen value for a default error status msg").mt_zdo.cL2200-L2232:MT_ZdoDirectCB()sends it as AREQ0x0040 | 0x80=0xC0(MT_ZDO_CID_TO_AREQ_ID, L113) withSrcAddr (2) + Status (1).mt.hL381:0xC0is alsoMT_ZDO_STATE_CHANGE_IND(one byte, the device state).Log
SALUS ST100ZB (lists endpoints
[9, 242], rejects 242 withINVALID_EP; see zigpy/zigpy#1966), Sonoff ZBDongle-P, Z-Stack 20240710, zigpy-znp 1.1.1. Both frames arrive in one read:The first frame is the default error response (
NWK 0xDED6, status0x82). The second is the fullSimple_Desc_rspviaMsgCbIncoming, which zigpy handles.Test
test_handling_zdo_default_error_rspfeeds the frame above and asserts nothing is logged at WARNING or above. It fails ondevwith the sameValueError.