Repository navigation
Raise a LaMetricError when a response does not fit its model - #1194
Merged
Merged
Conversation
A response this library could not parse, for example because a firmware update changed it, escaped as a raw mashumaro error. Home Assistant only catches LaMetricError, so it showed up as an unexpected error with a traceback, instead of something people could act on. Every model is now parsed through a small helper, that raises a LaMetricError naming who answered and what did not fit. A device response without a Wi-Fi block no longer trips a KeyError before that.
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.
Proposed Changes
A response this library could not parse, for example because a firmware update changed it, escaped as a raw mashumaro error (
MissingField,InvalidFieldValue, or aValueErrorwhen the response is not an object at all). Home Assistant only catchesLaMetricError, so each of these showed up as "Unexpected error" with a traceback. Going through the LaMetric issues in Home Assistant, a good chunk of the SKY reports were exactly that.Every model is now parsed through a small
_parsehelper on both clients, which raises aLaMetricErrornaming who answered and what did not fit, for example:Writing the test also turned up that
device()reshaped the Wi-Fi block before parsing, so a response without one tripped a rawKeyErrorfirst. That is now left to the parsing, which reports it like any other missing field.notification_queue()keeps skipping notifications it cannot parse; it now catches theLaMetricErrorinstead of the mashumaro errors.Related Issues
None in this repository. Found while going through the LaMetric issues in home-assistant/core.