Repository navigation
fix: log skipped discovery entities with context instead of a blank ERROR - #180
Conversation
…RROR add_list caught KeyError and called _LOGGER.error(error). For a trvcontrol product with no linked TRVs, get_device_data logged its own ERROR and then raised a bare KeyError, whose str() is empty, so Home Assistant showed a second, blank ERROR entry. get_device_data now raises KeyError with a message and no longer logs, and add_list logs one WARNING naming the entity type, Hive product type and id, and the missing key. Fixes home-assistant/core#172819 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #180 +/- ##
======================================
Coverage ? 99.96%
======================================
Files ? 30
Lines ? 2643
Branches ? 310
======================================
Hits ? 2642
Misses ? 0
Partials ? 1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 Claude Code ReviewLooks good: no bugs found. The PR fixes the blank log entry from a bare Bugs: none. Minor
Checked
Home Assistant check: I did not fetch the Home Assistant files. Home Assistant only reads Not reviewed: I did not run the test suite or linters. Automated review by Claude Code · workflow run |
Problem
home-assistant/core#172819 reports two ERROR entries at Hive setup, one of them completely blank:
For a
trvcontrolproduct whoseprops.trvslist is empty,HiveHelper.get_device_datalogged an ERROR and then raised a bareKeyError.DiscoveryMixin.add_listcaught it and called_LOGGER.error(error).str(KeyError())is an empty string, so the second entry had no text. The same blank entry appears for any otherKeyErrorwithout a message, such as a product whose parent device is missing.The source line in the report points at Home Assistant's setup call in
homeassistant/components/hive/__init__.py:Fix
get_device_dataraisesKeyError("no TRVs linked to trvcontrol product <id>")and no longer logs, so the skip is reported once.add_listlogs one WARNING with the entity type, the Hive product type and id, and the missing key. It falls back tounknown keyfor a bareKeyError.Example:
The level drops from ERROR to WARNING. The integration keeps working and only the affected entity is skipped, which matches Home Assistant's guidance for recoverable data problems.
Verification
tests/unit/test_discovery.pycover a bareKeyError, aKeyErrorwith a message, and product data with no id or type.tests/unit/test_helpers.pynow checks the message and that the helper logs nothing at ERROR.start_sessionagainst a real account with 8 heating and TRV zones: same 73 entities as before, no WARNING or ERROR lines.Home Assistant impact
No API, return-shape or exception change.
add_liststill returnsNonefor a skipped entity andstart_sessionreturns the samedevice_list. Only the log level and text change.🤖 Generated with Claude Code