Skip to content

fix: Handle unknown LifeSpan types gracefully in GetLifeSpan command - #1645

Open
L-pin wants to merge 5 commits into
DeebotUniverse:devfrom
L-pin:fix/handle-unknown-lifespan-types
Open

fix: Handle unknown LifeSpan types gracefully in GetLifeSpan command#1645
L-pin wants to merge 5 commits into
DeebotUniverse:devfrom
L-pin:fix/handle-unknown-lifespan-types

Conversation

@L-pin

@L-pin L-pin commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Problem

When a device returns a getLifeSpan response containing a type value not present
in the LifeSpan enum (e.g. after a firmware upgrade), the current implementation
raises a ValueError and aborts processing of the entire list. This means all
life span components silently lose their data, not just the unknown one.
This was observed on the T80s Pro (9jc32i) after a firmware upgrade, which started
returning three new types: dustBucket, dustContainerFilter, and
heavyDutyCleaningSolution.

Solution

  1. Add the three new LifeSpan enum members observed in the wild.
  2. Wrap the LifeSpan(component["type"]) call in a try/except ValueError so that
    unknown types are logged at DEBUG level and skipped, while all known components
    continue to be parsed correctly.

Testing

  • Added individual test cases for each of the three new enum values.
  • Added test_GetLifeSpan_unknown_type_skipped to verify that an unknown type does
    not prevent known components from being processed.

try:
component_type = LifeSpan(component["type"])
except ValueError:
_LOGGER.debug(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
_LOGGER.debug(
_LOGGER.warning(

Maybe we should just log it once and not for each one

Comment thread deebot_client/events/__init__.py Outdated
STATION_FILTER = "spHeap", "SpHeap"
WATER_SINK = "waterSink", "WaterSink"
MOP_WASHING_TRAY = "mopWashingTray", "mopWashingTray"
DUST_BUCKET = "dustBucket", "DustBucket"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please order them

@edenhaus
edenhaus marked this pull request as draft August 1, 2026 14:15
- Log all unknown LifeSpan types once per response instead of per item
- Sort LifeSpan enum members alphabetically
@L-pin

L-pin commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@edenhaus I've addressed both points:

life_span.py: Refactored to collect all unknown types during the loop and emit a single debug log at the end, rather than logging once per unknown component.
events/init.py: Sorted all LifeSpan enum members alphabetically so the three new entries land at their correct positions.

Keep alphabetically-sorted enum order from PR branch, add TRIMMER_BRUSH
and WEED_ROPE (from dev) at their correct alphabetical positions.
@L-pin
L-pin marked this pull request as ready for review August 1, 2026 16:19
Lpin added 2 commits August 2, 2026 00:21
- Wrap HEAVY_DUTY_CLEANING_SOLUTION tuple to multi-line (line too long)
- Remove extra blank line at end of LifeSpan enum
- Wrap long get_success_body call in test_life_span.py
ruff check requires all imports at module top-level, not inside functions.
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.31%. Comparing base (a094504) to head (230b383).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1645   +/-   ##
=======================================
  Coverage   96.30%   96.31%           
=======================================
  Files         161      161           
  Lines        6393     6402    +9     
  Branches      366      367    +1     
=======================================
+ Hits         6157     6166    +9     
  Misses        170      170           
  Partials       66       66           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq

codspeed-hq Bot commented Aug 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 226 untouched benchmarks


Comparing L-pin:fix/handle-unknown-lifespan-types (230b383) with dev (a094504)

Open in CodSpeed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants