Skip to content

Raise a LaMetricError when a response does not fit its model - #1194

Merged
frenck merged 1 commit into
mainfrom
frenck/wrap-parse-errors
Oct 3, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/wrap-parse-errors

Conversation

@frenck

@frenck frenck commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Proposed Changes

(Describe the changes and rationale behind them)

A response this library could not parse, for example because a firmware update changed it, escaped as a raw mashumaro error (MissingField, InvalidFieldValue, or a ValueError when the response is not an object at all). Home Assistant only catches LaMetricError, 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 _parse helper on both clients, which raises a LaMetricError naming who answered and what did not fit, for example:

The LaMetric device at 192.168.1.2 answered with data this library does not understand: Field "display" of type Display is missing in Device instance

Writing the test also turned up that device() reshaped the Wi-Fi block before parsing, so a response without one tripped a raw KeyError first. 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 the LaMetricError instead of the mashumaro errors.

Related Issues

(Github link to related issues or pull requests)

None in this repository. Found while going through the LaMetric issues in home-assistant/core.

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.
@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Oct 3, 2026
@frenck
frenck merged commit 527f7e6 into main Oct 3, 2026
32 checks passed
@frenck
frenck deleted the frenck/wrap-parse-errors branch October 3, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant