Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2093 +/- ##
==========================================
+ Coverage 84.31% 84.36% +0.04%
==========================================
Files 201 201
Lines 20656 20659 +3
Branches 1121 1122 +1
==========================================
+ Hits 17417 17429 +12
+ Misses 3047 3036 -11
- Partials 192 194 +2 ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
🟢 Approval recommended
The focused validation is correct and adequately covered by protocol-level regression tests.
0 open findings
What changed in this PR
Ensures non-object JSON device responses raise the established PayloadDecodeException instead of leaking TypeError.
Changes:
- Validate decoded responses are mappings before accessing fields.
- Add regression tests for invalid response shapes and valid objects.
| File | Description |
|---|---|
miio/miioprotocol.py |
Rejects non-object payloads with a device-level decode error. |
miio/tests/test_protocol.py |
Tests list, null, string, and object responses. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Valid JSON device responses such as a list, null, or a string currently reach
payload["id"]inMiIOProtocol.sendand raiseTypeError. Check that the decoded payload is a mapping and raise the existingPayloadDecodeException, so callers can handle it throughDeviceException.The regression tests use real encrypted message construction and
Message.parsefor each non-object JSON response, plus a valid object response to preserve normal result handling. Malformed JSON is already handled by the existing decoder and is unchanged.Validation: 20 protocol tests passed; Ruff and
git diff --checkpassed. This is a draft protocol robustness fix, with no Home Assistant deployment or device configuration changes.