Skip to content

Fix swallowed exceptions in knx action handlers #170618

@frenck

Description

@frenck

The knx integration catches exceptions in action handlers but only logs them instead of re-raising. This means the user gets no feedback in the UI when an action fails, and automations continue executing as if the action succeeded.

Affected methods in services.py:

  • service_event_register_modify (services.py)

How to fix:

Replace the except blocks that only log with ones that raise HomeAssistantError:

# Before (bad)
except SomeError as err:
    _LOGGER.error("Failed: %s", err)

# After (good)
except SomeError as err:
    raise HomeAssistantError(
        translation_domain=DOMAIN,
        translation_key="failed_to_turn_on",
    ) from err

Add the corresponding translation keys to strings.json. After fixing, remove the # pylint: disable-next=home-assistant-action-swallowed-exception comments.

Part of home-assistant/epics#64

Metadata

Metadata

Type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions