Skip to content

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

Merged
allenporter merged 1 commit into
Python-roborock:mainfrom
hCoureau:submit/fix/empty-list-trait-response
Nov 22, 2026
Merged

allenporter merged 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.

@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

@Lash-L Lash-L left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated code review by Gemini 4 Neon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).

Summary by Architectural Layer

  • Priority 1 — Public Trait APIs & Consumer Contracts (common.py, device_features.py, led_status.py, maps.py): Clean. All five single-record V1 converters (DefaultConverter, SingleValueConverter, DeviceTraitsConverter, LedStatusConverter, MultiMapsListConverter) now guard against empty list replies (and non-dict first elements in DeviceTraitsConverter) by raising ValueError, which V1TraitMixin.refresh() wraps into RoborockParsingException with command and payload context—matching the precedent set in #1034 (CleanRecordConverter). Legitimate empty-list V1 getters (RoomsConverter, CustomizeCleanModeConverter) remain untouched.
  • Priority 2 — Data Lifecycle & State Management: Clean. Raising before merge_trait_values() (and before cache writeback in DeviceFeaturesTrait.refresh()) preserves prior trait state and avoids caching malformed replies. All converters remain pure value-returning helpers.
  • Priority 3 — Wire Protocols, Codecs & Cryptography: No wire/codec changes; dynamic wire-payload type narrowing is properly scoped inside V1TraitDataConverter.convert().
  • Tests & CI: Clean. Regression tests are colocated in the matching mirror suites under tests/devices/traits/v1/ (including the new test_led_status.py mirroring led_status.py), reuse existing fixtures and parametrization, and verify both RoborockParsingException wrapping and state preservation. All CI checks pass.

Verdict

No findings survived adversarial self-check. This PR is clean, tightly scoped, and ready to approve.

@Lash-L Lash-L added /review run Code review skill (/review) has been run Passed /review Passed the /review skill check labels Nov 21, 2026
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 340034a to d5c2ce7 Compare November 21, 2026 21:36
@allenporter

Copy link
Copy Markdown
Contributor

Thanks for the cleanup @hCoureau

@allenporter
allenporter merged commit 85d7514 into Python-roborock:main Nov 22, 2026
9 checks passed
@hCoureau
hCoureau deleted the submit/fix/empty-list-trait-response branch November 22, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Passed /review Passed the /review skill check /review run Code review skill (/review) has been run Small PR Small pull request (<200 lines) V1 V1 platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants