Skip to content

fix(v1): report empty trait list replies as parsing errors - #1056

Open
hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/fix/empty-list-trait-response
Open

hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/fix/empty-list-trait-response

Conversation

@hCoureau

@hCoureau hCoureau commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Context

V1 traits parse device replies through converters, and V1TraitMixin.refresh() turns a converter's ValueError into RoborockParsingException carrying the command and payload. #1034 made CleanRecordConverter reject empty replies this way.

Problem

DefaultConverter, SingleValueConverter, MultiMapsListConverter, LedStatusConverter and DeviceTraitsConverter take the first element of a list reply without checking that the list is non-empty, and DeviceTraitsConverter also passes a non-dict first element to from_dict. An empty or malformed reply therefore raises IndexError or AttributeError from refresh() instead of RoborockParsingException.

Changes

  • These five converters raise ValueError for an empty list, and DeviceTraitsConverter also for a non-dict element.
  • refresh() already wraps that as RoborockParsingException; the trait keeps its previous values.
  • Valid replies are parsed as before.

Testing

  • New regression tests through the public traits for each converter: an empty list, plus a non-dict element for device features. All six cases fail with IndexError or AttributeError without the fix.
  • 2,367 tests passed on each of Python 3.11 and 3.14, on current main.
  • pre-commit, commitlint and source/wheel builds passed.

Evidence

  • On a Qrevo 2 Pro (roborock.vacuum.a294, firmware 02.40.54), normal replies for 14 traits still parse through all five converters with this change.
  • The empty and non-dict cases use simulated replies only. I have not seen a device send these shapes for these commands.

DefaultConverter, SingleValueConverter, MultiMapsListConverter,
LedStatusConverter and DeviceTraitsConverter indexed the first element
of a list reply without checking for an empty list, and
DeviceTraitsConverter passed a non-dict element to from_dict. These
raised IndexError or AttributeError instead of RoborockParsingException.
They now raise ValueError, which refresh() wraps as a parsing error,
leaving the previous values in place.
@hCoureau
hCoureau force-pushed the submit/fix/empty-list-trait-response branch from 0003065 to 340034a Compare November 16, 2026 21:24
@Lash-L Lash-L added Small PR Small pull request (<200 lines) bug Something isn't working V1 V1 platform labels Nov 18, 2026

This branch has not been deployed

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

Labels

bug Something isn't working Small PR Small pull request (<200 lines) V1 V1 platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants