Skip to content

Pass subscription errors to an on_error callback - #259

Merged
natekspencer merged 2 commits into
mainfrom
vehicle-updates-on-error
Nov 17, 2026
Merged

natekspencer merged 2 commits into
mainfrom
vehicle-updates-on-error

Conversation

@natekspencer

Copy link
Copy Markdown
Collaborator

subscribe_for_vehicle_updates, subscribe_for_departure_schedules and subscribe_for_parallax_messages take an optional, keyword-only on_error, passed to _start_subscription the way subscribe_for_parallax_command_state already uses it.

Why

When a subscription asks for a field that fails GraphQL validation, Rivian accepts the subscription, then sends an error message ("Cannot query field …") and no data. Without an on_error, the client only logs that at debug level, so the caller can't tell its subscription has stopped.

The integration's GraphQL position fixes (bretterer/home-assistant-rivian#355) are a subscription of their own, so that kind of failure falls back to Parallax's fixes without breaking anything. With this, the integration can also log a warning when it happens.

Changes

  • src/rivian/rivian.py: the on_error parameter and docstrings. Existing callers are unaffected.
  • tests/test_ws_monitor.py: for each of the three, an error from the server reaches on_error. These fail without the change.

Testing

373 tests pass; ruff and mypy are clean.

🤖 Generated with Claude Code

natekspencer and others added 2 commits November 17, 2026 02:19
subscribe_for_vehicle_updates, subscribe_for_departure_schedules and
subscribe_for_parallax_messages take an optional, keyword-only on_error,
which gets the subscription's error messages. A field that fails GraphQL
validation, for example, ends the subscription with an error message and no
data; without on_error that's only logged at debug level, so the caller
can't tell its subscription has stopped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reconnect subscribes again, so a subscription that keeps failing calls
on_error each time until it's unsubscribed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@natekspencer
natekspencer merged commit faac48a into main Nov 17, 2026
6 checks passed
@natekspencer
natekspencer deleted the vehicle-updates-on-error branch November 17, 2026 02:29
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.

1 participant