Skip to content

Raise InvalidDefaultResponse on unsuccessful default response#1778

Draft
puddly wants to merge 13 commits intozigpy:devfrom
puddly:puddly/raise-on-bad-default-response
Draft

Raise InvalidDefaultResponse on unsuccessful default response#1778
puddly wants to merge 13 commits intozigpy:devfrom
puddly:puddly/raise-on-bad-default-response

Conversation

@puddly
Copy link
Collaborator

@puddly puddly commented Feb 25, 2026

This PR changes zigpy's behavior with default responses: any default response with a status code other than SUCCESS will turn into an exception. This is still a bit annoying to deal with typing-wise because practically any request can be responded to with a default response with a SUCCESS status code. We should perhaps modify our request sending to explicitly opt into accepting a default response, with the default being not to?

Most general commands have been moved to exact types: for example, foundation.DefaultResponse. The same has been done for the attribute reading and writing commands. This allows us to more precisely pass around these response types and to fully restrict the types of read_attributes_raw, write_attributes_raw, and configure_reporting_raw. (This unfortunately brings up an issue with zigpy that has no simple fix: our easy-to-define schema={"param": type} is utterly unusable by type checkers).


Related: zigpy/zha#678

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.46%. Comparing base (c81f158) to head (33bea88).

Files with missing lines Patch % Lines
zigpy/zcl/__init__.py 93.54% 4 Missing ⚠️
zigpy/endpoint.py 60.00% 2 Missing ⚠️
zigpy/device.py 66.66% 1 Missing ⚠️
zigpy/quirks/__init__.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1778      +/-   ##
==========================================
- Coverage   99.51%   99.46%   -0.06%     
==========================================
  Files          63       63              
  Lines       12778    12825      +47     
==========================================
+ Hits        12716    12756      +40     
- Misses         62       69       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant