Skip to content

Coordinator ValueErrors surface unhandled (traceback + no clean message) on service calls #501

@tempus2016

Description

@tempus2016

Problem

Service handlers that route into coordinator methods raising bare ValueError (locked-avatar choose_avatar, over-balance / self / unknown-child gift_points, unknown-id undo_transaction, request_swap, task-group ops, etc.) surface the error unhandled. Over the frontend WebSocket path (the cards, the admin panel, Dev Tools "Perform action") this becomes a failed call with no clean message and a full traceback in the HA log on every routine rejection.

Verified on the ha-dev instance (HA 2026.6.3): gift_points over balance, gift_points to self, choose_avatar with a locked avatar, undo_transaction/request_swap with a bad id all produced unhandled errors + tracebacks. State was never corrupted — the validations correctly reject the bad op; only the error handling was wrong. The card UI already guards the avatar gate client-side, so the main impact is automations/Dev Tools callers and log spam.

Fix

Wrap the service handlers so coordinator ValueError is re-raised as homeassistant.exceptions.ServiceValidationError (the same pattern complete_chore already uses). ServiceValidationError returns a clean service_validation_error result over the WebSocket API with the human-readable message and is logged as a single line, not a traceback.

A reusable _safe decorator is composed into the existing _admin wrapper (covers all admin-gated handlers) and applied to the remaining bare handlers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendIntegration / coordinator / config flowbugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions